# reading in data (De-identified starting new student groups)
deidgroup <- read.csv("C:/Users/khanj/Desktop/Khan_CampusResources_StudyOne.csv")
deidgroup <- as.data.frame(deidgroup)

# Creating new variables for Condition 
deidgroup$Liberal <- NA
deidgroup$Conservative <- NA
deidgroup$Control <- NA

# Column 16: Liberal (Liberal Condition = 1; All other conditions = 0)
deidgroup[, 16][deidgroup[, 15] == "Conservative"] <- 0
deidgroup[, 16][deidgroup[, 15] == "Liberal"] <- 1
deidgroup[, 16][deidgroup[, 15] == "Control"] <- 0

# Column 17: Conservative (Conservative Condition = 1; All other conditions = 0)
deidgroup[, 17][deidgroup[, 15] == "Conservative"] <- 1
deidgroup[, 17][deidgroup[, 15] == "Liberal"] <- 0
deidgroup[, 17][deidgroup[, 15] == "Control"] <- 0

# Column 18: Control (Control Condition = 1; All other conditions = 0)
deidgroup[, 18][deidgroup[, 15] == "Conservative"] <- 0
deidgroup[, 18][deidgroup[, 15] == "Liberal"] <- 0
deidgroup[, 18][deidgroup[, 15] == "Control"] <- 1

# transforming control variables into numeric form
deidgroup$enrollment <- as.numeric(deidgroup$enrollment)
deidgroup$endowment <- as.numeric(deidgroup$endowment)
deidgroup$ranking <- as.numeric(deidgroup$ranking)

# Balance Tests for all emails sent
# Balance Test Model- Liberal
# Any college characteristics predict being in the Liberal Treatment?
liberal_balance <-glm(as.numeric(Liberal) ~ 
                        + I(setting=="urban")
                      + I(setting=="rural")
                      + endowment + enrollment + ranking
                      + I(region=="North") 
                      + I(region=="South") 
                      + I(region=="West") 
                      + I(religious==1)
                      + as.factor(num_school_type),
                      data = deidgroup, 
                      family = binomial(link = "logit"))

summary(liberal_balance)

# Balance Test Model- Conservative
# Any college characteristics predict being in the Conservative Treatment?
conservative_balance <-glm(as.numeric(Conservative) ~ 
                             + I(setting=="urban")
                           + I(setting=="rural")
                           + endowment + enrollment + ranking
                           + I(region=="North") 
                           + I(region=="South") 
                           + I(region=="West") 
                           + I(religious==1)
                           + as.factor(num_school_type),
                           data = deidgroup, 
                           family = binomial(link = "logit"))

summary(conservative_balance)

# Balance Test Model- Control
# Any college characteristics predict being in the Control Condition?
control_balance <-glm(as.numeric(Control) ~ I(setting=="urban")
                      + I(setting=="rural")
                      + endowment + enrollment + ranking
                      + I(region=="North") 
                      + I(region=="South") 
                      + I(region=="West") 
                      + I(religious==1)
                      + as.factor(num_school_type),
                      data = deidgroup, 
                      family = binomial(link = "logit"))

summary(control_balance)

# Balance Test/ Equivalency Check Tables- All Emails Sent
# Liberal- All Emails Sent 
install.packages("Hmisc")
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(liberal_balance$coefficients), digits = 2)
Variables[ ,2] <- round(summary(liberal_balance)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(liberal_balance)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Test/ Equivalency Check Tables
# Conservative- All Emails Sent
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(conservative_balance$coefficients), digits = 2)
Variables[ ,2] <- round(summary(conservative_balance)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(conservative_balance)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Test/ Equivalency Check Tables
# Control- All Emails Sent 
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(control_balance$coefficients), digits = 2)
Variables[ ,2] <- round(summary(control_balance)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(control_balance)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Test- all valid emails (undeliverable and auto-replies deleted)
# Creating dataset without undeliverable and auto-replies
exclude_autoreply <- deidgroup[deidgroup$replies != "NA", ]

# Balance Tests for all emails sent
# Balance Test Model- Liberal
# Any college characteristics predict being in the Liberal Treatment?
liberal_balance_excludeauto <-glm(as.numeric(Liberal) ~ 
                                    + I(setting=="urban")
                                  + I(setting=="rural")
                                  + endowment + enrollment + ranking
                                  + I(region=="North") 
                                  + I(region=="South") 
                                  + I(region=="West") 
                                  + I(religious==1)
                                  + as.factor(num_school_type),
                                  data = exclude_autoreply, 
                                  family = binomial(link = "logit"))

summary(liberal_balance_excludeauto)

# Balance Test Model- Conservative
# Any college characteristics predict being in the Conservative Treatment?
conservative_balance_excludeauto <-glm(as.numeric(Conservative) ~ 
                                         + I(setting=="urban")
                                       + I(setting=="rural")
                                       + endowment + enrollment + ranking
                                       + I(region=="North") 
                                       + I(region=="South") 
                                       + I(region=="West") 
                                       + I(religious==1)
                                       + as.factor(num_school_type),
                                       data = exclude_autoreply, 
                                       family = binomial(link = "logit"))

summary(conservative_balance_excludeauto)

# Balance Test Model- Control
# Any college characteristics predict being in the Control Condition?
control_balance_excludeauto <-glm(as.numeric(Control) ~ I(setting=="urban")
                                  + I(setting=="rural")
                                  + endowment + enrollment + ranking
                                  + I(region=="North") 
                                  + I(region=="South") 
                                  + I(region=="West") 
                                  + I(religious==1)
                                  + as.factor(num_school_type),
                                  data = exclude_autoreply, 
                                  family = binomial(link = "logit"))

summary(control_balance_excludeauto)

# Balance Test/ Equivalency Check Tables- autoreplies and undeliverables excluded
# Liberal- autoreplies and undeliverables excluded
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(liberal_balance_excludeauto$coefficients), digits = 2)
Variables[ ,2] <- round(summary(liberal_balance_excludeauto)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(liberal_balance_excludeauto)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Test/ Equivalency Check Tables- autoreplies and undeliverables excluded
# Conservative- autoreplies and undeliverables excluded
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(conservative_balance_excludeauto$coefficients), digits = 2)
Variables[ ,2] <- round(summary(conservative_balance_excludeauto)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(conservative_balance_excludeauto)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Test/ Equivalency Check Tables-autoreplies and undeliverables excluded
# Control- All Emails Sent-autoreplies and undeliverables excluded 
library(Hmisc)
Variables <- matrix(NA, 13 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious", "National Liberal Arts",
                         "Regional Universities", "Regional Colleges") 
Variables[ ,1] <- round(as.numeric(control_balance_excludeauto$coefficients), digits = 2)
Variables[ ,2] <- round(summary(control_balance_excludeauto)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(control_balance_excludeauto)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Creating and Coding new DVs: Substantive and Days to Reply
deidgroup$substantive <- 0
deidgroup$days <- 31

# coding substantive replies
deidgroup$substantive[5] <- 1
deidgroup$substantive[7] <- 1
deidgroup$substantive[8] <- 1
deidgroup$substantive[9] <- 1
deidgroup$substantive[10] <- 1
deidgroup$substantive[11] <- 1
deidgroup$substantive[14] <- 1
deidgroup$substantive[16] <- 1
deidgroup$substantive[20] <- 1
deidgroup$substantive[21] <- 1
deidgroup$substantive[22] <- 1
deidgroup$substantive[24] <- 1
deidgroup$substantive[27] <- NA
deidgroup$substantive[36] <- 1
deidgroup$substantive[37] <- 1
deidgroup$substantive[38] <- NA
deidgroup$substantive[39] <- 1
deidgroup$substantive[40] <- 1
deidgroup$substantive[41] <- 1
deidgroup$substantive[42] <- 1
deidgroup$substantive[43] <- 1
deidgroup$substantive[44] <- 1
deidgroup$substantive[45] <- 1
deidgroup$substantive[46] <- NA
deidgroup$substantive[47] <- NA
deidgroup$substantive[61] <- 1
deidgroup$substantive[62] <- 1
deidgroup$substantive[63] <- 1
deidgroup$substantive[64] <- 1
deidgroup$substantive[65] <- NA
deidgroup$substantive[66] <- 1
deidgroup$substantive[67] <- 1
deidgroup$substantive[68] <- 1
deidgroup$substantive[69] <- 1
deidgroup$substantive[70] <- 1
deidgroup$substantive[71] <- NA
deidgroup$substantive[78] <- 1
deidgroup$substantive[80] <- 1
deidgroup$substantive[81] <- 1
deidgroup$substantive[82] <- 1
deidgroup$substantive[83] <- 1
deidgroup$substantive[84] <- 1
deidgroup$substantive[85] <- 1
deidgroup$substantive[86] <- 1
deidgroup$substantive[87] <- 1
deidgroup$substantive[93] <- 1
deidgroup$substantive[94] <- 1
deidgroup$substantive[95] <- 1
deidgroup$substantive[96] <- 1
deidgroup$substantive[97] <- 1
deidgroup$substantive[98] <- 1
deidgroup$substantive[99] <- 1
deidgroup$substantive[100] <- 1
deidgroup$substantive[101] <- 1
deidgroup$substantive[102] <- 1
deidgroup$substantive[103] <- 1
deidgroup$substantive[104] <- 1
deidgroup$substantive[105] <- 1
deidgroup$substantive[106] <- 1
deidgroup$substantive[107] <- 1
deidgroup$substantive[108] <- 1
deidgroup$substantive[110] <- NA
deidgroup$substantive[114] <- 1
deidgroup$substantive[115] <- 1
deidgroup$substantive[116] <- 1
deidgroup$substantive[117] <- 1
deidgroup$substantive[118] <- 1
deidgroup$substantive[119] <- 1
deidgroup$substantive[120] <- 1
deidgroup$substantive[122] <- 1
deidgroup$substantive[123] <- 1
deidgroup$substantive[124] <- NA
deidgroup$substantive[125] <- 1
deidgroup$substantive[126] <- 1
deidgroup$substantive[127] <- NA
deidgroup$substantive[128] <- NA
deidgroup$substantive[137] <- 1
deidgroup$substantive[139] <- 1
deidgroup$substantive[140] <- 1
deidgroup$substantive[141] <- 1
deidgroup$substantive[142] <- 1
deidgroup$substantive[143] <- 1
deidgroup$substantive[144] <- 1
deidgroup$substantive[145] <- 1
deidgroup$substantive[171] <- 1
deidgroup$substantive[172] <- 1
deidgroup$substantive[174] <- 1
deidgroup$substantive[175] <- 1
deidgroup$substantive[176] <- 1
deidgroup$substantive[177] <- 1
deidgroup$substantive[178] <- 1
deidgroup$substantive[179] <- 1
deidgroup$substantive[180] <- 1
deidgroup$substantive[181] <- 1
deidgroup$substantive[182] <- 1
deidgroup$substantive[183] <- 1
deidgroup$substantive[184] <- 1
deidgroup$substantive[185] <- 1
deidgroup$substantive[186] <- 1
deidgroup$substantive[187] <- 1
deidgroup$substantive[188] <- 1
deidgroup$substantive[189] <- 1
deidgroup$substantive[191] <- 1
deidgroup$substantive[192] <- 1
deidgroup$substantive[195] <- 1
deidgroup$substantive[196] <- 1
deidgroup$substantive[197] <- 1
deidgroup$substantive[198] <- 1
deidgroup$substantive[199] <- 1
deidgroup$substantive[200] <- 1
deidgroup$substantive[201] <- 1
deidgroup$substantive[202] <- 1
deidgroup$substantive[203] <- 1 
deidgroup$substantive[204] <- 1
deidgroup$substantive[205] <- 0
deidgroup$substantive[206] <- 0
deidgroup$substantive[207] <- 1
deidgroup$substantive[208] <- NA
deidgroup$substantive[209] <- NA
deidgroup$substantive[210] <- 0
deidgroup$substantive[211] <- 0
deidgroup$substantive[212] <- 0
deidgroup$substantive[213] <- 0
deidgroup$substantive[214] <- 0
deidgroup$substantive[215] <- 0
deidgroup$substantive[216] <- 0
deidgroup$substantive[217] <- 0
deidgroup$substantive[218] <- 0
deidgroup$substantive[219] <- 0
deidgroup$substantive[220] <- 0
deidgroup$substantive[221] <- 0
deidgroup$substantive[222] <- 0
deidgroup$substantive[223] <- 0
deidgroup$substantive[224] <- 0
deidgroup$substantive[225] <- 0
deidgroup$substantive[226] <- 0
deidgroup$substantive[227] <- 0
deidgroup$substantive[228] <- 0
deidgroup$substantive[229] <- 0
deidgroup$substantive[230] <- 0
deidgroup$substantive[231] <- 0
deidgroup$substantive[232] <- 1
deidgroup$substantive[233] <- 1
deidgroup$substantive[234] <- 1
deidgroup$substantive[235] <- 1
deidgroup$substantive[236] <- 0
deidgroup$substantive[237] <- 1
deidgroup$substantive[238] <- 1
deidgroup$substantive[239] <- 1
deidgroup$substantive[240] <- 1
deidgroup$substantive[241] <- NA
deidgroup$substantive[242] <- 0
deidgroup$substantive[243] <- 0
deidgroup$substantive[244] <- 1
deidgroup$substantive[245] <- 1
deidgroup$substantive[246] <- 1
deidgroup$substantive[247] <- 1
deidgroup$substantive[248] <- 1
deidgroup$substantive[249] <- 1
deidgroup$substantive[250] <- 1
deidgroup$substantive[251] <- 1
deidgroup$substantive[252] <- 1
deidgroup$substantive[253] <- 1
deidgroup$substantive[254] <- 1
deidgroup$substantive[255] <- 1
deidgroup$substantive[256] <- 1
deidgroup$substantive[257] <- 1
deidgroup$substantive[259] <- 1
deidgroup$substantive[260] <- 1
deidgroup$substantive[261] <- 1
deidgroup$substantive[264] <- NA
deidgroup$substantive[265] <- NA
deidgroup$substantive[266] <- NA
deidgroup$substantive[287] <- 1
deidgroup$substantive[288] <- 1
deidgroup$substantive[289] <- 1
deidgroup$substantive[290] <- 1
deidgroup$substantive[291] <- 1
deidgroup$substantive[292] <- 1
deidgroup$substantive[293] <- 1
deidgroup$substantive[294] <- 1
deidgroup$substantive[295] <- 1
deidgroup$substantive[296] <- 1
deidgroup$substantive[297] <- 1
deidgroup$substantive[298] <- 1
deidgroup$substantive[299] <- 1
deidgroup$substantive[300] <- 1
deidgroup$substantive[301] <- 1
deidgroup$substantive[302] <- 1
deidgroup$substantive[303] <- 1
deidgroup$substantive[304] <- 1
deidgroup$substantive[305] <- 1
deidgroup$substantive[306] <- 1
deidgroup$substantive[307] <- 1
deidgroup$substantive[308] <- 1
deidgroup$substantive[309] <- 1
deidgroup$substantive[310] <- 1
deidgroup$substantive[311] <- 1
deidgroup$substantive[312] <- 1
deidgroup$substantive[313] <- 1
deidgroup$substantive[314] <- 1
deidgroup$substantive[315] <- 0
deidgroup$substantive[316] <- 1
deidgroup$substantive[317] <- 1
deidgroup$substantive[318] <- 1
deidgroup$substantive[319] <- 0
deidgroup$substantive[320] <- 1
deidgroup$substantive[321] <- 1
deidgroup$substantive[322] <- NA
deidgroup$substantive[323] <- NA
deidgroup$substantive[332] <- 1
deidgroup$substantive[333] <- 1
deidgroup$substantive[334] <- 1
deidgroup$substantive[335] <- 1
deidgroup$substantive[336] <- 1
deidgroup$substantive[337] <- 1
deidgroup$substantive[338] <- 1
deidgroup$substantive[339] <- 1
deidgroup$substantive[340] <- 1
deidgroup$substantive[341] <- 1
deidgroup$substantive[342] <- 1
deidgroup$substantive[343] <- NA
deidgroup$substantive[344] <- NA
deidgroup$substantive[353] <- 1
deidgroup$substantive[354] <- 1
deidgroup$substantive[355] <- 0
deidgroup$substantive[356] <- 1
deidgroup$substantive[357] <- 1
deidgroup$substantive[358] <- 1
deidgroup$substantive[359] <- 0
deidgroup$substantive[360] <- 1
deidgroup$substantive[361] <- 1
deidgroup$substantive[362] <- 1
deidgroup$substantive[363] <- 1
deidgroup$substantive[373] <- 1
deidgroup$substantive[374] <- 1
deidgroup$substantive[375] <- 1
deidgroup$substantive[376] <- 1
deidgroup$substantive[377] <- 0
deidgroup$substantive[378] <- 1
deidgroup$substantive[379] <- 1
deidgroup$substantive[380] <- NA
deidgroup$substantive[381] <- 1
deidgroup$substantive[382] <- 1
deidgroup$substantive[383] <- 1
deidgroup$substantive[384] <- 1
deidgroup$substantive[385] <- 1
deidgroup$substantive[386] <- 1
deidgroup$substantive[387] <- 1
deidgroup$substantive[388] <- 1
deidgroup$substantive[389] <- 1
deidgroup$substantive[390] <- 1
deidgroup$substantive[391] <- NA
deidgroup$substantive[392] <- NA
deidgroup$substantive[403] <- 1
deidgroup$substantive[404] <- 1
deidgroup$substantive[405] <- 0
deidgroup$substantive[406] <- 1
deidgroup$substantive[407] <- 0
deidgroup$substantive[408] <- 1
deidgroup$substantive[409] <- 1
deidgroup$substantive[410] <- 1
deidgroup$substantive[411] <- 1
deidgroup$substantive[412] <- 0
deidgroup$substantive[413] <- 0
deidgroup$substantive[414] <- 1
deidgroup$substantive[415] <- 1
deidgroup$substantive[416] <- 0
deidgroup$substantive[417] <- 1
deidgroup$substantive[418] <- 1
deidgroup$substantive[419] <- 1
deidgroup$substantive[420] <- 1
deidgroup$substantive[421] <- 1
deidgroup$substantive[422] <- 1
deidgroup$substantive[423] <- 1
deidgroup$substantive[424] <- 1
deidgroup$substantive[425] <- 1
deidgroup$substantive[426] <- 1
deidgroup$substantive[427] <- 1
deidgroup$substantive[428] <- 0
deidgroup$substantive[429] <- 0
deidgroup$substantive[430] <- 1
deidgroup$substantive[431] <- 1
deidgroup$substantive[432] <- 1
deidgroup$substantive[433] <- 1
deidgroup$substantive[434] <- 1
deidgroup$substantive[435] <- 0
deidgroup$substantive[436] <- 1
deidgroup$substantive[437] <- 1
deidgroup$substantive[438] <- 0
deidgroup$substantive[439] <- 1
deidgroup$substantive[440] <- 1
deidgroup$substantive[441] <- 1
deidgroup$substantive[442] <- 1
deidgroup$substantive[443] <- 1
deidgroup$substantive[444] <- 1
deidgroup$substantive[445] <- 1
deidgroup$substantive[446] <- 0
deidgroup$substantive[447] <- 1
deidgroup$substantive[448] <- 1
deidgroup$substantive[449] <- 1
deidgroup$substantive[450] <- 1
deidgroup$substantive[451] <- 1
deidgroup$substantive[452] <- 1
deidgroup$substantive[453] <- NA
deidgroup$substantive[454] <- NA
deidgroup$substantive[455] <- NA
deidgroup$substantive[456] <- NA
deidgroup$substantive[484] <- 1
deidgroup$substantive[485] <- 1
deidgroup$substantive[486] <- 1
deidgroup$substantive[487] <- 1
deidgroup$substantive[488] <- 1
deidgroup$substantive[489] <- 1
deidgroup$substantive[490] <- 1
deidgroup$substantive[491] <- 1
deidgroup$substantive[492] <- 1
deidgroup$substantive[493] <- 1
deidgroup$substantive[494] <- 1
deidgroup$substantive[495] <- 1
deidgroup$substantive[496] <- 1
deidgroup$substantive[497] <- 1
deidgroup$substantive[498] <- 1
deidgroup$substantive[499] <- 1
deidgroup$substantive[500] <- 1
deidgroup$substantive[501] <- 1
deidgroup$substantive[502] <- 0
deidgroup$substantive[503] <- 1
deidgroup$substantive[504] <- 1
deidgroup$substantive[505] <- 1
deidgroup$substantive[506] <- 1
deidgroup$substantive[507] <- 1
deidgroup$substantive[508] <- 1
deidgroup$substantive[509] <- 1
deidgroup$substantive[510] <- 1
deidgroup$substantive[511] <- 1
deidgroup$substantive[512] <- 1
deidgroup$substantive[513] <- 1
deidgroup$substantive[514] <- 0
deidgroup$substantive[515] <- 1
deidgroup$substantive[516] <- 1
deidgroup$substantive[517] <- 1
deidgroup$substantive[518] <- 1
deidgroup$substantive[519] <- 1
deidgroup$substantive[520] <- 1
deidgroup$substantive[521] <- 1
deidgroup$substantive[522] <- 1
deidgroup$substantive[523] <- 1
deidgroup$substantive[524] <- 1
deidgroup$substantive[525] <- 1
deidgroup$substantive[526] <- 1
deidgroup$substantive[527] <- NA
deidgroup$substantive[528] <- NA
deidgroup$substantive[529] <- NA
deidgroup$substantive[530] <- NA
deidgroup$substantive[531] <- NA
deidgroup$substantive[532] <- NA
deidgroup$substantive[553] <- 1
deidgroup$substantive[554] <- 1
deidgroup$substantive[555] <- 1
deidgroup$substantive[556] <- 1
deidgroup$substantive[557] <- 1
deidgroup$substantive[558] <- 0
deidgroup$substantive[559] <- 0
deidgroup$substantive[560] <- 1
deidgroup$substantive[561] <- 1
deidgroup$substantive[562] <- 1
deidgroup$substantive[563] <- 1
deidgroup$substantive[564] <- 0
deidgroup$substantive[565] <- 1
deidgroup$substantive[566] <- NA
deidgroup$substantive[567] <- 1
deidgroup$substantive[568] <- 1
deidgroup$substantive[569] <- 1
deidgroup$substantive[570] <- 1
deidgroup$substantive[571] <- 1
deidgroup$substantive[572] <- 1
deidgroup$substantive[573] <- 1
deidgroup$substantive[574] <- 1
deidgroup$substantive[575] <- 1
deidgroup$substantive[576] <- 1
deidgroup$substantive[577] <- 1
deidgroup$substantive[578] <- 1
deidgroup$substantive[579] <- 1
deidgroup$substantive[580] <- 1
deidgroup$substantive[581] <- 1
deidgroup$substantive[582] <- 1
deidgroup$substantive[583] <- 1
deidgroup$substantive[584] <- 1
deidgroup$substantive[585] <- 1
deidgroup$substantive[586] <- 1
deidgroup$substantive[587] <- 1
deidgroup$substantive[588] <- 0
deidgroup$substantive[589] <- 1
deidgroup$substantive[590] <- 1
deidgroup$substantive[591] <- 1
deidgroup$substantive[592] <- 1
deidgroup$substantive[593] <- 1
deidgroup$substantive[594] <- 1
deidgroup$substantive[595] <- 1
deidgroup$substantive[596] <- 0
deidgroup$substantive[597] <- 1
deidgroup$substantive[598] <- 1
deidgroup$substantive[599] <- 1
deidgroup$substantive[600] <- 1
deidgroup$substantive[601] <- 1
deidgroup$substantive[602] <- 1
deidgroup$substantive[603] <- 1
deidgroup$substantive[604] <- 1
deidgroup$substantive[605] <- NA
deidgroup$substantive[606] <- NA
deidgroup$substantive[607] <- NA
deidgroup$substantive[608] <- NA
deidgroup$substantive[615] <- 1
deidgroup$substantive[616] <- 1
deidgroup$substantive[617] <- 1
deidgroup$substantive[618] <- 1
deidgroup$substantive[619] <- 0
deidgroup$substantive[620] <- 1
deidgroup$substantive[621] <- 1
deidgroup$substantive[622] <- 1
deidgroup$substantive[623] <- NA
deidgroup$substantive[631] <- 1
deidgroup$substantive[632] <- 1
deidgroup$substantive[633] <- 1
deidgroup$substantive[634] <- 1
deidgroup$substantive[635] <- 1
deidgroup$substantive[636] <- 1
deidgroup$substantive[637] <- 1
deidgroup$substantive[638] <- 1
deidgroup$substantive[639] <- 1
deidgroup$substantive[640] <- 1
deidgroup$substantive[641] <- 1
deidgroup$substantive[642] <- NA
deidgroup$substantive[643] <- NA
deidgroup$substantive[649] <- 1
deidgroup$substantive[650] <- 1
deidgroup$substantive[651] <- 1
deidgroup$substantive[652] <- 1
deidgroup$substantive[653] <- 1
deidgroup$substantive[654] <- 1
deidgroup$substantive[655] <- 1
deidgroup$substantive[656] <- 1
deidgroup$substantive[657] <- 1
deidgroup$substantive[658] <- 1
deidgroup$substantive[659] <- 1
deidgroup$substantive[660] <- 1
deidgroup$substantive[661] <- NA
deidgroup$substantive[662] <- NA
deidgroup$substantive[663] <- NA
deidgroup$substantive[676] <- 1
deidgroup$substantive[677] <- 1
deidgroup$substantive[678] <- 1
deidgroup$substantive[679] <- 1
deidgroup$substantive[680] <- 1
deidgroup$substantive[681] <- 0
deidgroup$substantive[682] <- 1
deidgroup$substantive[683] <- 1
deidgroup$substantive[684] <- 1
deidgroup$substantive[685] <- 1
deidgroup$substantive[686] <- 1
deidgroup$substantive[687] <- 1
deidgroup$substantive[688] <- 1
deidgroup$substantive[689] <- 1
deidgroup$substantive[690] <- 1
deidgroup$substantive[691] <- 1
deidgroup$substantive[692] <- 1
deidgroup$substantive[693] <- 1
deidgroup$substantive[694] <- 1
deidgroup$substantive[695] <- 1
deidgroup$substantive[696] <- 1
deidgroup$substantive[697] <- 1
deidgroup$substantive[698] <- 1
deidgroup$substantive[699] <- 1
deidgroup$substantive[700] <- 1
deidgroup$substantive[701] <- 1
deidgroup$substantive[702] <- 1
deidgroup$substantive[703] <- 1
deidgroup$substantive[704] <- 1
deidgroup$substantive[705] <- 1
deidgroup$substantive[706] <- 1
deidgroup$substantive[707] <- 1
deidgroup$substantive[708] <- 1
deidgroup$substantive[709] <- 1
deidgroup$substantive[710] <- 1
deidgroup$substantive[711] <- 1
deidgroup$substantive[712] <- 1
deidgroup$substantive[713] <- 0
deidgroup$substantive[714] <- 1
deidgroup$substantive[715] <- 1
deidgroup$substantive[716] <- 1
deidgroup$substantive[717] <- NA
deidgroup$substantive[718] <- NA
deidgroup$substantive[731] <- 1
deidgroup$substantive[732] <- 1
deidgroup$substantive[733] <- 1
deidgroup$substantive[734] <- 1
deidgroup$substantive[735] <- 1
deidgroup$substantive[736] <- 1
deidgroup$substantive[737] <- 1
deidgroup$substantive[738] <- 0
deidgroup$substantive[739] <- 1
deidgroup$substantive[740] <- 1
deidgroup$substantive[741] <- 1
deidgroup$substantive[742] <- 1
deidgroup$substantive[743] <- 1
deidgroup$substantive[744] <- 1
deidgroup$substantive[745] <- 1
deidgroup$substantive[746] <- 1
deidgroup$substantive[747] <- 1
deidgroup$substantive[748] <- 1
deidgroup$substantive[749] <- 1
deidgroup$substantive[750] <- 1
deidgroup$substantive[751] <- 1
deidgroup$substantive[752] <- 1
deidgroup$substantive[753] <- 1
deidgroup$substantive[754] <- NA
deidgroup$substantive[755] <- 1
deidgroup$substantive[756] <- 1
deidgroup$substantive[757] <- 1
deidgroup$substantive[758] <- 1
deidgroup$substantive[759] <- 1
deidgroup$substantive[760] <- 1
deidgroup$substantive[761] <- NA
deidgroup$substantive[762] <- NA
deidgroup$substantive[772] <- 1
deidgroup$substantive[773] <- 1
deidgroup$substantive[774] <- 1
deidgroup$substantive[775] <- 1
deidgroup$substantive[776] <- 1
deidgroup$substantive[777] <- 1
deidgroup$substantive[778] <- 1
deidgroup$substantive[779] <- 1
deidgroup$substantive[780] <- 1
deidgroup$substantive[781] <- 1
deidgroup$substantive[782] <- 1
deidgroup$substantive[783] <- 1
deidgroup$substantive[784] <- 1
deidgroup$substantive[785] <- 1
deidgroup$substantive[786] <- 1
deidgroup$substantive[787] <- 1
deidgroup$substantive[788] <- 1
deidgroup$substantive[789] <- 1
deidgroup$substantive[790] <- 1
deidgroup$substantive[791] <- 1
deidgroup$substantive[792] <- 1
deidgroup$substantive[793] <- 1
deidgroup$substantive[794] <- 1
deidgroup$substantive[795] <- 1
deidgroup$substantive[796] <- 1
deidgroup$substantive[797] <- 1
deidgroup$substantive[798] <- 1
deidgroup$substantive[799] <- 0
deidgroup$substantive[800] <- 1
deidgroup$substantive[801] <- 1
deidgroup$substantive[802] <- 1
deidgroup$substantive[803] <- NA
deidgroup$substantive[812] <- 1
deidgroup$substantive[813] <- 1
deidgroup$substantive[814] <- 1
deidgroup$substantive[815] <- 1
deidgroup$substantive[816] <- 1
deidgroup$substantive[817] <- 1
deidgroup$substantive[818] <- 1
deidgroup$substantive[819] <- NA
deidgroup$substantive[820] <- 1
deidgroup$substantive[821] <- 1
deidgroup$substantive[822] <- NA
deidgroup$substantive[829] <- 1
deidgroup$substantive[830] <- 1
deidgroup$substantive[831] <- 1
deidgroup$substantive[832] <- 1
deidgroup$substantive[833] <- 1
deidgroup$substantive[834] <- 1
deidgroup$substantive[835] <- 1
deidgroup$substantive[836] <- 1
deidgroup$substantive[837] <- 1
deidgroup$substantive[838] <- 1
deidgroup$substantive[839] <- 1
deidgroup$substantive[840] <- 0
deidgroup$substantive[841] <- 1
deidgroup$substantive[842] <- 1
deidgroup$substantive[843] <- 1
deidgroup$substantive[844] <- NA
deidgroup$substantive[849] <- 1
deidgroup$substantive[850] <- 1
deidgroup$substantive[851] <- 1
deidgroup$substantive[852] <- 0
deidgroup$substantive[853] <- 1
deidgroup$substantive[854] <- 1
deidgroup$substantive[855] <- 1
deidgroup$substantive[856] <- 1
deidgroup$substantive[857] <- 1
deidgroup$substantive[858] <- 1
deidgroup$substantive[859] <- 1
deidgroup$substantive[860] <- 1
deidgroup$substantive[861] <- 1
deidgroup$substantive[862] <- NA
deidgroup$substantive[863] <- NA
deidgroup$substantive[864] <- NA
deidgroup$substantive[880] <- 1
deidgroup$substantive[881] <- 1
deidgroup$substantive[882] <- 1
deidgroup$substantive[883] <- 1
deidgroup$substantive[884] <- 1
deidgroup$substantive[885] <- 1
deidgroup$substantive[886] <- 1
deidgroup$substantive[887] <- 1
deidgroup$substantive[888] <- 1
deidgroup$substantive[889] <- 1
deidgroup$substantive[890] <- 1
deidgroup$substantive[891] <- 1
deidgroup$substantive[892] <- 1
deidgroup$substantive[893] <- 1
deidgroup$substantive[894] <- 1
deidgroup$substantive[895] <- 1
deidgroup$substantive[896] <- 1
deidgroup$substantive[897] <- 1
deidgroup$substantive[898] <- 1
deidgroup$substantive[899] <- 0
deidgroup$substantive[900] <- 1
deidgroup$substantive[901] <- 1
deidgroup$substantive[902] <- 0
deidgroup$substantive[903] <- 1
deidgroup$substantive[904] <- 1
deidgroup$substantive[905] <- 1
deidgroup$substantive[906] <- 1
deidgroup$substantive[907] <- 1
deidgroup$substantive[908] <- 1
deidgroup$substantive[909] <- 1
deidgroup$substantive[910] <- 1
deidgroup$substantive[911] <- 1
deidgroup$substantive[912] <- 1
deidgroup$substantive[913] <- 1
deidgroup$substantive[914] <- NA
deidgroup$substantive[928] <- 1
deidgroup$substantive[929] <- 1
deidgroup$substantive[930] <- 1
deidgroup$substantive[931] <- 1
deidgroup$substantive[932] <- 1
deidgroup$substantive[933] <- 1
deidgroup$substantive[934] <- 1
deidgroup$substantive[935] <- 1
deidgroup$substantive[936] <- 1
deidgroup$substantive[937] <- 1
deidgroup$substantive[938] <- 1
deidgroup$substantive[939] <- 1
deidgroup$substantive[940] <- NA
deidgroup$substantive[941] <- 1
deidgroup$substantive[942] <- 1
deidgroup$substantive[943] <- 1
deidgroup$substantive[944] <- 1
deidgroup$substantive[945] <- 1
deidgroup$substantive[946] <- 1
deidgroup$substantive[947] <- NA
deidgroup$substantive[948] <- 0
deidgroup$substantive[949] <- 1
deidgroup$substantive[950] <- 0
deidgroup$substantive[951] <- 1
deidgroup$substantive[952] <- 1
deidgroup$substantive[953] <- 1
deidgroup$substantive[954] <- 1
deidgroup$substantive[955] <- 1
deidgroup$substantive[956] <- 1
deidgroup$substantive[957] <- 1
deidgroup$substantive[958] <- 1
deidgroup$substantive[959] <- 1
deidgroup$substantive[960] <- 0
deidgroup$substantive[961] <- 1
deidgroup$substantive[962] <- 1
deidgroup$substantive[963] <- 1
deidgroup$substantive[964] <- NA
deidgroup$substantive[979] <- 1
deidgroup$substantive[980] <- 1
deidgroup$substantive[981] <- 1
deidgroup$substantive[982] <- 0
deidgroup$substantive[983] <- 1
deidgroup$substantive[984] <- 1
deidgroup$substantive[985] <- 1
deidgroup$substantive[986] <- 1
deidgroup$substantive[987] <- 1
deidgroup$substantive[988] <- 1
deidgroup$substantive[989] <- 1
deidgroup$substantive[990] <- 1
deidgroup$substantive[991] <- 1
deidgroup$substantive[992] <- 1
deidgroup$substantive[993] <- 1
deidgroup$substantive[994] <- 1
deidgroup$substantive[995] <- 1
deidgroup$substantive[996] <- 1
deidgroup$substantive[997] <- 1
deidgroup$substantive[998] <- 1
deidgroup$substantive[999] <- 1
deidgroup$substantive[1000] <- 1
deidgroup$substantive[1001] <- 1
deidgroup$substantive[1002] <- 1
deidgroup$substantive[1003] <- 1
deidgroup$substantive[1004] <- 1
deidgroup$substantive[1005] <- 1
deidgroup$substantive[1006] <- 1
deidgroup$substantive[1007] <- 1
deidgroup$substantive[1008] <- 1
deidgroup$substantive[1009] <- 1
deidgroup$substantive[1010] <- 1
deidgroup$substantive[1011] <- 1
deidgroup$substantive[1012] <- NA
deidgroup$substantive[1013] <- NA
deidgroup$substantive[1014] <- NA
deidgroup$substantive[1015] <- NA
deidgroup$substantive[1016] <- NA
deidgroup$substantive[1021] <- 1
deidgroup$substantive[1022] <- 1
deidgroup$substantive[1027] <- 0
deidgroup$substantive[1028] <- 1
deidgroup$substantive[1029] <- 0
deidgroup$substantive[1030] <- 1
deidgroup$substantive[1035] <- 0
deidgroup$substantive[1036] <- 1
deidgroup$substantive[1037] <- 1
deidgroup$substantive[1038] <- 0
deidgroup$substantive[1040] <- 1
deidgroup$substantive[1041] <- 0
deidgroup$substantive[1047] <- 1
deidgroup$substantive[1048] <- 1
deidgroup$substantive[1049] <- 1
deidgroup$substantive[1050] <- 1
deidgroup$substantive[1051] <- 0
deidgroup$substantive[1052] <- 1
deidgroup$substantive[1053] <- 1
deidgroup$substantive[1059] <- 1
deidgroup$substantive[1060] <- 1
deidgroup$substantive[1061] <- 1
deidgroup$substantive[1062] <- 1
deidgroup$substantive[1063] <- 1
deidgroup$substantive[1064] <- 1
deidgroup$substantive[1066] <- 1
deidgroup$substantive[1068] <- 1
deidgroup$substantive[1069] <- 1
deidgroup$substantive[1070] <- 1
deidgroup$substantive[1071] <- 1
deidgroup$substantive[1072] <- NA
deidgroup$substantive[1078] <- 1
deidgroup$substantive[1079] <- 0
deidgroup$substantive[1080] <- 1
deidgroup$substantive[1081] <- 1
deidgroup$substantive[1082] <- 1
deidgroup$substantive[1083] <- 1
deidgroup$substantive[1084] <- 1
deidgroup$substantive[1085] <- 1
deidgroup$substantive[1086] <- 1
deidgroup$substantive[1094] <- 1
deidgroup$substantive[1095] <- 1
deidgroup$substantive[1096] <- 1
deidgroup$substantive[1097] <- 1
deidgroup$substantive[1098] <- 1
deidgroup$substantive[1099] <- 1
deidgroup$substantive[1100] <- NA
deidgroup$substantive[1110] <- 1
deidgroup$substantive[1111] <- 1
deidgroup$substantive[1113] <- 1
deidgroup$substantive[1114] <- 1
deidgroup$substantive[1115] <- 1
deidgroup$substantive[1116] <- NA
deidgroup$substantive[1117] <- NA
deidgroup$substantive[1131] <- 1
deidgroup$substantive[1132] <- 1
deidgroup$substantive[1133] <- 1
deidgroup$substantive[1134] <- 1
deidgroup$substantive[1135] <- 1
deidgroup$substantive[1136] <- 0
deidgroup$substantive[1137] <- 1
deidgroup$substantive[1138] <- 1
deidgroup$substantive[1139] <- 1
deidgroup$substantive[1140] <- 1
deidgroup$substantive[1141] <- 1
deidgroup$substantive[1142] <- 1
deidgroup$substantive[1143] <- 1
deidgroup$substantive[1144] <- 1
deidgroup$substantive[1145] <- 1
deidgroup$substantive[1146] <- 1
deidgroup$substantive[1148] <- NA
deidgroup$substantive[1153] <- 1
deidgroup$substantive[1155] <- 1
deidgroup$substantive[1156] <- 1
deidgroup$substantive[1157] <- 1
deidgroup$substantive[1158] <- 1
deidgroup$substantive[1159] <- 1
deidgroup$substantive[1160] <- 1
deidgroup$substantive[1161] <- 1
deidgroup$substantive[1162] <- NA
deidgroup$substantive[1167] <- 1
deidgroup$substantive[1168] <- 1
deidgroup$substantive[1169] <- 0
deidgroup$substantive[1170] <- 1
deidgroup$substantive[1171] <- NA
deidgroup$substantive[1179] <- 1
deidgroup$substantive[1180] <- 1
deidgroup$substantive[1181] <- 1
deidgroup$substantive[1182] <- 1
deidgroup$substantive[1183] <- 1
deidgroup$substantive[1197] <- 1
deidgroup$substantive[1198] <- 1
deidgroup$substantive[1199] <- 0
deidgroup$substantive[1200] <- 1
deidgroup$substantive[1201] <- 1
deidgroup$substantive[1202] <- 1
deidgroup$substantive[1203] <- 1
deidgroup$substantive[1204] <- 1
deidgroup$substantive[1205] <- 1
deidgroup$substantive[1206] <- 0
deidgroup$substantive[1207] <- 1
deidgroup$substantive[1208] <- 1
deidgroup$substantive[1209] <- 1
deidgroup$substantive[1210] <- 1
deidgroup$substantive[1211] <- 1
deidgroup$substantive[1212] <- 1
deidgroup$substantive[1213] <- 1
deidgroup$substantive[1214] <- 1
deidgroup$substantive[1215] <- 1
deidgroup$substantive[1216] <- 0
deidgroup$substantive[1217] <- 1
deidgroup$substantive[1218] <- 1
deidgroup$substantive[1219] <- 1
deidgroup$substantive[1220] <- 1
deidgroup$substantive[1221] <- 1
deidgroup$substantive[1222] <- 1
deidgroup$substantive[1223] <- 1
deidgroup$substantive[1224] <- 1
deidgroup$substantive[1225] <- NA
deidgroup$substantive[1253] <- 1
deidgroup$substantive[1254] <- 1
deidgroup$substantive[1255] <- 1
deidgroup$substantive[1256] <- 1
deidgroup$substantive[1257] <- 1
deidgroup$substantive[1258] <- 1
deidgroup$substantive[1259] <- 1
deidgroup$substantive[1260] <- 1
deidgroup$substantive[1261] <- 1
deidgroup$substantive[1262] <- 1
deidgroup$substantive[1263] <- 1
deidgroup$substantive[1264] <- 0
deidgroup$substantive[1265] <- 1
deidgroup$substantive[1266] <- 1
deidgroup$substantive[1267] <- 1
deidgroup$substantive[1268] <- 1
deidgroup$substantive[1269] <- 1
deidgroup$substantive[1270] <- 1
deidgroup$substantive[1271] <- 1
deidgroup$substantive[1272] <- 0
deidgroup$substantive[1273] <- 1
deidgroup$substantive[1274] <- 1
deidgroup$substantive[1275] <- 1
deidgroup$substantive[1276] <- 1
deidgroup$substantive[1277] <- NA
deidgroup$substantive[1291] <- 1
deidgroup$substantive[1292] <- 1
deidgroup$substantive[1293] <- 1
deidgroup$substantive[1294] <- 1
deidgroup$substantive[1295] <- 1
deidgroup$substantive[1296] <- 1
deidgroup$substantive[1297] <- 1
deidgroup$substantive[1298] <- 1
deidgroup$substantive[1299] <- 1
deidgroup$substantive[1300] <- 1
deidgroup$substantive[1301] <- 0
deidgroup$substantive[1302] <- 1
deidgroup$substantive[1304] <- 1
deidgroup$substantive[1305] <- 1
deidgroup$substantive[1306] <- 1
deidgroup$substantive[1307] <- 1
deidgroup$substantive[1308] <- 1
deidgroup$substantive[1309] <- 1
deidgroup$substantive[1310] <- 0
deidgroup$substantive[1311] <- 1
deidgroup$substantive[1312] <- 1
deidgroup$substantive[1313] <- 1
deidgroup$substantive[1314] <- 1
deidgroup$substantive[1315] <- 0
deidgroup$substantive[1316] <- 1
deidgroup$substantive[1318] <- NA
deidgroup$substantive[1319] <- NA
deidgroup$substantive[1324] <- 1
deidgroup$substantive[1325] <- NA
deidgroup$substantive[1328] <- 1
deidgroup$substantive[1329] <- 0
deidgroup$substantive[1330] <- 1
deidgroup$substantive[1331] <- 1
deidgroup$substantive[1332] <- NA
deidgroup$substantive[1335] <- 1
deidgroup$substantive[1336] <- 1
deidgroup$substantive[1337] <- 1
deidgroup$substantive[1338] <- 1
deidgroup$substantive[1343] <- 1
deidgroup$substantive[1344] <- 1
deidgroup$substantive[1345] <- 1
deidgroup$substantive[1346] <- 1
deidgroup$substantive[1347] <- 1
deidgroup$substantive[1348] <- 1
deidgroup$substantive[1349] <- 1
deidgroup$substantive[1350] <- 1
deidgroup$substantive[1351] <- 1
deidgroup$substantive[1352] <- 0
deidgroup$substantive[1353] <- 1
deidgroup$substantive[1354] <- 1
deidgroup$substantive[1359] <- 1
deidgroup$substantive[1360] <- 1
deidgroup$substantive[1361] <- 0
deidgroup$substantive[1362] <- 1
deidgroup$substantive[1363] <- 1
deidgroup$substantive[1364] <- 1
deidgroup$substantive[1365] <- 1
deidgroup$substantive[1366] <- 0
deidgroup$substantive[1367] <- 1
deidgroup$substantive[1368] <- 1
deidgroup$substantive[1369] <- 1
deidgroup$substantive[1370] <- 1
deidgroup$substantive[1371] <- 1
deidgroup$substantive[1372] <- NA
deidgroup$substantive[1380] <- 1
deidgroup$substantive[1381] <- 1
deidgroup$substantive[1382] <- 1
deidgroup$substantive[1383] <- 1
deidgroup$substantive[1385] <- 0
deidgroup$substantive[1386] <- 1
deidgroup$substantive[1387] <- 1
deidgroup$substantive[1388] <- 1
deidgroup$substantive[1389] <- 1
deidgroup$substantive[1390] <- 1
deidgroup$substantive[1391] <- NA
deidgroup$substantive[1393] <- 1
deidgroup$substantive[1394] <- 1
deidgroup$substantive[1395] <- 1
deidgroup$substantive[1396] <- 0
deidgroup$substantive[1397] <- NA
deidgroup$substantive[1399] <- 1
deidgroup$substantive[1400] <- 1
deidgroup$substantive[1403] <- 1
deidgroup$substantive[1404] <- 1
deidgroup$substantive[1405] <- 1
deidgroup$substantive[1415] <- 1
deidgroup$substantive[1416] <- 1
deidgroup$substantive[1417] <- 1
deidgroup$substantive[1419] <- 1
deidgroup$substantive[1420] <- 1
deidgroup$substantive[1421] <- 1
deidgroup$substantive[1422] <- 1
deidgroup$substantive[1423] <- 1
deidgroup$substantive[1424] <- 1
deidgroup$substantive[1425] <- 1
deidgroup$substantive[1426] <- 1
deidgroup$substantive[1427] <- 1
deidgroup$substantive[1428] <- 1
deidgroup$substantive[1429] <- 1
deidgroup$substantive[1430] <- 1
deidgroup$substantive[1433] <- 1
deidgroup$substantive[1434] <- 1
deidgroup$substantive[1435] <- 1
deidgroup$substantive[1436] <- 1
deidgroup$substantive[1437] <- 1
deidgroup$substantive[1438] <- 1
deidgroup$substantive[1439] <- 1
deidgroup$substantive[1440] <- 1
deidgroup$substantive[1441] <- 1
deidgroup$substantive[1442] <- 0
deidgroup$substantive[1443] <- 0
deidgroup$substantive[1444] <- 1
deidgroup$substantive[1445] <- 1
deidgroup$substantive[1446] <- NA
deidgroup$substantive[1456] <- 1
deidgroup$substantive[1457] <- 1
deidgroup$substantive[1458] <- 1
deidgroup$substantive[1459] <- 1
deidgroup$substantive[1460] <- 1
deidgroup$substantive[1461] <- 1
deidgroup$substantive[1462] <- 1
deidgroup$substantive[1463] <- 0
deidgroup$substantive[1464] <- 1
deidgroup$substantive[1465] <- 0
deidgroup$substantive[1467] <- 1
deidgroup$substantive[1468] <- 1
deidgroup$substantive[1469] <- 1
deidgroup$substantive[1470] <- 1

# coding days to reply
deidgroup$days[4] <- 8
deidgroup$days[5] <- 1
deidgroup$days[6] <- 0
deidgroup$days[7] <- 0
deidgroup$days[8] <- 0
deidgroup$days[9] <- 0
deidgroup$days[10] <- 0
deidgroup$days[11] <- 0
deidgroup$days[12] <- 1
deidgroup$days[14] <- 0
deidgroup$days[16] <- 3
deidgroup$days[17] <- 0
deidgroup$days[18] <- 0
deidgroup$days[20] <- 0
deidgroup$days[21] <- 0
deidgroup$days[22] <- 1
deidgroup$days[23] <- 0
deidgroup$days[24] <- 0
deidgroup$days[25] <- 1
deidgroup$days[26] <- 1
deidgroup$days[27] <- NA
deidgroup$days[28] <- 0
deidgroup$days[29] <- 4
deidgroup$days[30] <- 0
deidgroup$days[31] <- 0
deidgroup$days[32] <- 5
deidgroup$days[36] <- 5
deidgroup$days[37] <- 0
deidgroup$days[38] <- NA
deidgroup$days[39] <- 1
deidgroup$days[40] <- 1
deidgroup$days[41] <- 0
deidgroup$days[42] <- 1
deidgroup$days[43] <- 0
deidgroup$days[44] <- 0
deidgroup$days[45] <- 0
deidgroup$days[46] <- NA
deidgroup$days[47] <- NA
deidgroup$days[49] <- 0
deidgroup$days[50] <- 0
deidgroup$days[51] <- 0
deidgroup$days[53] <- 0
deidgroup$days[54] <- 0
deidgroup$days[55] <- 0
deidgroup$days[56] <- 1
deidgroup$days[60] <- 1
deidgroup$days[61] <- 1
deidgroup$days[62] <- 0
deidgroup$days[63] <- 0
deidgroup$days[64] <- 0
deidgroup$days[65] <- NA
deidgroup$days[66] <- 0
deidgroup$days[67] <- 1
deidgroup$days[68] <- 1
deidgroup$days[69] <- 0
deidgroup$days[70] <- 0
deidgroup$days[71] <- NA
deidgroup$days[73] <- 0
deidgroup$days[77] <- 0
deidgroup$days[78] <- 0
deidgroup$days[80] <- 0
deidgroup$days[81] <- 0
deidgroup$days[82] <- 1
deidgroup$days[83] <- 1
deidgroup$days[84] <- 0
deidgroup$days[85] <- 0
deidgroup$days[86] <- 0
deidgroup$days[87] <- 0
deidgroup$days[90] <- 1
deidgroup$days[93] <- 6
deidgroup$days[94] <- 15
deidgroup$days[95] <- 0
deidgroup$days[96] <- 1
deidgroup$days[97] <- 1
deidgroup$days[98] <- 1
deidgroup$days[99] <- 1
deidgroup$days[100] <- 0
deidgroup$days[101] <- 10
deidgroup$days[102] <- 0
deidgroup$days[103] <- 0
deidgroup$days[104] <- 0
deidgroup$days[105] <- 2
deidgroup$days[106] <- 0
deidgroup$days[107] <- 0
deidgroup$days[108] <- 0
deidgroup$days[110] <- NA
deidgroup$days[112] <- 0
deidgroup$days[114] <- 10
deidgroup$days[115] <- 15
deidgroup$days[116] <- 1
deidgroup$days[117] <- 1
deidgroup$days[118] <- 1
deidgroup$days[119] <- 1
deidgroup$days[120] <- 1
deidgroup$days[122] <- 2
deidgroup$days[123] <- 0
deidgroup$days[124] <- NA
deidgroup$days[125] <- 1
deidgroup$days[126] <- 0
deidgroup$days[127] <- NA
deidgroup$days[128] <- NA
deidgroup$days[129] <- 0
deidgroup$days[130] <- 0
deidgroup$days[131] <- 0
deidgroup$days[132] <- 0
deidgroup$days[137] <- 6
deidgroup$days[138] <- 0
deidgroup$days[139] <- 0
deidgroup$days[140] <- 0
deidgroup$days[141] <- 0
deidgroup$days[142] <- 2
deidgroup$days[143] <- 0
deidgroup$days[144] <- 2
deidgroup$days[145] <- 8
deidgroup$days[147] <- 0
deidgroup$days[149] <- 0
deidgroup$days[156] <- 0
deidgroup$days[158] <- 0
deidgroup$days[160] <- 0
deidgroup$days[162] <- 0
deidgroup$days[165] <- 3
deidgroup$days[168] <- 0
deidgroup$days[170] <- 2
deidgroup$days[171] <- 1
deidgroup$days[172] <- 0
deidgroup$days[173] <- 0
deidgroup$days[174] <- 0
deidgroup$days[175] <- 0
deidgroup$days[176] <- 0
deidgroup$days[177] <- 0
deidgroup$days[178] <- 0
deidgroup$days[179] <- 2
deidgroup$days[180] <- 0
deidgroup$days[181] <- 5
deidgroup$days[182] <- 0
deidgroup$days[183] <- 0
deidgroup$days[184] <- 0
deidgroup$days[185] <- 6
deidgroup$days[186] <- 0
deidgroup$days[187] <- 1
deidgroup$days[188] <- 0
deidgroup$days[189] <- 0
deidgroup$days[190] <- 0
deidgroup$days[191] <- 0
deidgroup$days[192] <- 2
deidgroup$days[193] <- 1
deidgroup$days[194] <- 0
deidgroup$days[195] <- 0
deidgroup$days[196] <- 0
deidgroup$days[197] <- 1
deidgroup$days[198] <- 0
deidgroup$days[199] <- 1
deidgroup$days[200] <- 1
deidgroup$days[201] <- 0
deidgroup$days[202] <- 2
deidgroup$days[203] <- 0
deidgroup$days[204] <- 1
deidgroup$days[205] <- 0
deidgroup$days[206] <- 2
deidgroup$days[207] <- 1
deidgroup$days[208] <- NA
deidgroup$days[209] <- NA
deidgroup$days[210] <- 0
deidgroup$days[214] <- 0
deidgroup$days[216] <- 5
deidgroup$days[217] <- 3
deidgroup$days[218] <- 0
deidgroup$days[219] <- 0
deidgroup$days[221] <- 9
deidgroup$days[222] <- 0
deidgroup$days[225] <- 0
deidgroup$days[227] <- 0
deidgroup$days[230] <- 2
deidgroup$days[231] <- 0
deidgroup$days[232] <- 5
deidgroup$days[233] <- 8
deidgroup$days[234] <- 0
deidgroup$days[235] <- 0
deidgroup$days[236] <- 0
deidgroup$days[237] <- 0
deidgroup$days[238] <- 6
deidgroup$days[239] <- 1
deidgroup$days[240] <- 0
deidgroup$days[241] <- NA
deidgroup$days[242] <- 0
deidgroup$days[243] <- 2
deidgroup$days[244] <- 0
deidgroup$days[245] <- 1
deidgroup$days[246] <- 2
deidgroup$days[247] <- 0
deidgroup$days[248] <- 1
deidgroup$days[249] <- 1
deidgroup$days[250] <- 1
deidgroup$days[251] <- 1
deidgroup$days[252] <- 1
deidgroup$days[253] <- 0
deidgroup$days[254] <- 0
deidgroup$days[255] <- 11
deidgroup$days[256] <- 0
deidgroup$days[257] <- 0
deidgroup$days[258] <- 2
deidgroup$days[259] <- 0
deidgroup$days[260] <- 7
deidgroup$days[261] <- 1
deidgroup$days[262] <- 7
deidgroup$days[263] <- 2
deidgroup$days[264] <- NA
deidgroup$days[265] <- NA
deidgroup$days[266] <- NA
deidgroup$days[267] <- 5
deidgroup$days[269] <- 0
deidgroup$days[271] <- 0
deidgroup$days[272] <- 0
deidgroup$days[273] <- 0
deidgroup$days[274] <- 0
deidgroup$days[276] <- 2
deidgroup$days[278] <- 2
deidgroup$days[280] <- 0
deidgroup$days[281] <- 2
deidgroup$days[282] <- 0
deidgroup$days[283] <- 8
deidgroup$days[284] <- 1
deidgroup$days[285] <- 1
deidgroup$days[287] <- 0
deidgroup$days[288] <- 1
deidgroup$days[289] <- 0
deidgroup$days[290] <- 0
deidgroup$days[291] <- 2
deidgroup$days[292] <- 0
deidgroup$days[293] <- 0
deidgroup$days[294] <- 0
deidgroup$days[295] <- 0
deidgroup$days[296] <- 1
deidgroup$days[297] <- 0
deidgroup$days[298] <- 0
deidgroup$days[299] <- 0
deidgroup$days[300] <- 0
deidgroup$days[301] <- 0
deidgroup$days[302] <- 0
deidgroup$days[303] <- 0
deidgroup$days[304] <- 0
deidgroup$days[305] <- 1
deidgroup$days[306] <- 3
deidgroup$days[307] <- 0
deidgroup$days[308] <- 2
deidgroup$days[309] <- 12
deidgroup$days[310] <- 0
deidgroup$days[311] <- 6
deidgroup$days[312] <- 0
deidgroup$days[313] <- 1
deidgroup$days[314] <- 3
deidgroup$days[315] <- 0
deidgroup$days[316] <- 0
deidgroup$days[317] <- 0
deidgroup$days[318] <- 0
deidgroup$days[319] <- 0
deidgroup$days[320] <- 2
deidgroup$days[321] <- 1
deidgroup$days[322] <- NA
deidgroup$days[323] <- NA
deidgroup$days[324] <- 0
deidgroup$days[325] <- 0
deidgroup$days[326] <- 0
deidgroup$days[327] <- 1
deidgroup$days[329] <- 3
deidgroup$days[330] <- 1
deidgroup$days[332] <- 1
deidgroup$days[333] <- 0
deidgroup$days[334] <- 0
deidgroup$days[335] <- 2
deidgroup$days[336] <- 1
deidgroup$days[337] <- 0
deidgroup$days[338] <- 8
deidgroup$days[339] <- 2
deidgroup$days[340] <- 0
deidgroup$days[341] <- 0
deidgroup$days[342] <- 0
deidgroup$days[343] <- NA
deidgroup$days[344] <- NA
deidgroup$days[345] <- 0
deidgroup$days[346] <- 0
deidgroup$days[347] <- 1
deidgroup$days[348] <- 1
deidgroup$days[350] <- 13
deidgroup$days[351] <- 1
deidgroup$days[353] <- 0
deidgroup$days[354] <- 0
deidgroup$days[355] <- 0
deidgroup$days[356] <- 1
deidgroup$days[357] <- 1
deidgroup$days[358] <- 0
deidgroup$days[359] <- 1
deidgroup$days[360] <- 0
deidgroup$days[361] <- 1
deidgroup$days[362] <- 0
deidgroup$days[363] <- 1
deidgroup$days[364] <- 0
deidgroup$days[365] <- 1
deidgroup$days[367] <- 0
deidgroup$days[368] <- 0
deidgroup$days[369] <- 0
deidgroup$days[372] <- 0
deidgroup$days[373] <- 1
deidgroup$days[374] <- 0
deidgroup$days[375] <- 1
deidgroup$days[376] <- 0
deidgroup$days[377] <- 0
deidgroup$days[378] <- 0
deidgroup$days[379] <- 0
deidgroup$days[380] <- NA
deidgroup$days[381] <- 1
deidgroup$days[382] <- 1
deidgroup$days[383] <- 0
deidgroup$days[384] <- 2
deidgroup$days[385] <- 0
deidgroup$days[386] <- 1
deidgroup$days[387] <- 0
deidgroup$days[388] <- 0
deidgroup$days[389] <- 0
deidgroup$days[390] <- 3
deidgroup$days[391] <- NA
deidgroup$days[392] <- NA
deidgroup$days[393] <- 0
deidgroup$days[394] <- 0
deidgroup$days[395] <- 0
deidgroup$days[396] <- 7
deidgroup$days[397] <- 0
deidgroup$days[398] <- 1
deidgroup$days[399] <- 1
deidgroup$days[400] <- 0
deidgroup$days[401] <- 0
deidgroup$days[402] <- 2
deidgroup$days[403] <- 9
deidgroup$days[404] <- 1
deidgroup$days[405] <- 0
deidgroup$days[406] <- 0
deidgroup$days[407] <- 1
deidgroup$days[408] <- 0
deidgroup$days[409] <- 0
deidgroup$days[410] <- 7
deidgroup$days[411] <- 0
deidgroup$days[412] <- 0
deidgroup$days[413] <- 9
deidgroup$days[414] <- 0
deidgroup$days[415] <- 0
deidgroup$days[416] <- 1
deidgroup$days[417] <- 0
deidgroup$days[418] <- 1
deidgroup$days[419] <- 0
deidgroup$days[420] <- 0
deidgroup$days[421] <- 0
deidgroup$days[422] <- 0
deidgroup$days[423] <- 0
deidgroup$days[424] <- 1
deidgroup$days[425] <- 1
deidgroup$days[426] <- 0
deidgroup$days[427] <- 0
deidgroup$days[428] <- 0
deidgroup$days[429] <- 0
deidgroup$days[430] <- 0
deidgroup$days[431] <- 1
deidgroup$days[432] <- 1
deidgroup$days[433] <- 0
deidgroup$days[434] <- 0
deidgroup$days[435] <- 1
deidgroup$days[436] <- 14
deidgroup$days[437] <- 0
deidgroup$days[438] <- 6
deidgroup$days[439] <- 5
deidgroup$days[440] <- 0
deidgroup$days[441] <- 0
deidgroup$days[442] <- 0
deidgroup$days[443] <- 0
deidgroup$days[444] <- 0
deidgroup$days[445] <- 3
deidgroup$days[446] <- 0
deidgroup$days[447] <- 1
deidgroup$days[448] <- 0
deidgroup$days[449] <- 1
deidgroup$days[450] <- 0
deidgroup$days[451] <- 1
deidgroup$days[452] <- 0
deidgroup$days[453] <- NA
deidgroup$days[454] <- NA
deidgroup$days[455] <- NA
deidgroup$days[456] <- NA
deidgroup$days[457] <- 1
deidgroup$days[458] <- 0
deidgroup$days[459] <- 18
deidgroup$days[460] <- 1
deidgroup$days[461] <- 8
deidgroup$days[462] <- 1
deidgroup$days[463] <- 0
deidgroup$days[465] <- 0
deidgroup$days[466] <- 1
deidgroup$days[467] <- 0
deidgroup$days[469] <- 0
deidgroup$days[470] <- 0
deidgroup$days[471] <- 0
deidgroup$days[472] <- 3
deidgroup$days[473] <- 0
deidgroup$days[475] <- 6
deidgroup$days[476] <- 0
deidgroup$days[477] <- 0
deidgroup$days[481] <- 1
deidgroup$days[482] <- 0
deidgroup$days[483] <- 3
deidgroup$days[484] <- 0
deidgroup$days[485] <- 11
deidgroup$days[486] <- 0
deidgroup$days[487] <- 0
deidgroup$days[488] <- 2
deidgroup$days[489] <- 2
deidgroup$days[490] <- 2
deidgroup$days[491] <- 0
deidgroup$days[492] <- 0
deidgroup$days[493] <- 0
deidgroup$days[494] <- 0
deidgroup$days[495] <- 0
deidgroup$days[496] <- 0
deidgroup$days[497] <- 1
deidgroup$days[498] <- 0
deidgroup$days[499] <- 0
deidgroup$days[500] <- 0
deidgroup$days[501] <- 0
deidgroup$days[502] <- 0
deidgroup$days[503] <- 0
deidgroup$days[504] <- 0
deidgroup$days[505] <- 0
deidgroup$days[506] <- 0
deidgroup$days[507] <- 0
deidgroup$days[508] <- 3
deidgroup$days[509] <- 0
deidgroup$days[510] <- 0
deidgroup$days[511] <- 1
deidgroup$days[512] <- 6
deidgroup$days[513] <- 0
deidgroup$days[514] <- 1
deidgroup$days[515] <- 0
deidgroup$days[516] <- 0
deidgroup$days[517] <- 0
deidgroup$days[518] <- 0
deidgroup$days[519] <- 0
deidgroup$days[520] <- 1
deidgroup$days[521] <- 1
deidgroup$days[522] <- 1
deidgroup$days[523] <- 2
deidgroup$days[524] <- 2
deidgroup$days[525] <- 0
deidgroup$days[526] <- 1
deidgroup$days[527] <- NA
deidgroup$days[528] <- NA
deidgroup$days[529] <- NA
deidgroup$days[530] <- NA
deidgroup$days[531] <- NA
deidgroup$days[532] <- NA
deidgroup$days[533] <- 0
deidgroup$days[541] <- 0
deidgroup$days[544] <- 0
deidgroup$days[545] <- 2
deidgroup$days[547] <- 0
deidgroup$days[548] <- 0
deidgroup$days[549] <- 1
deidgroup$days[551] <- 0
deidgroup$days[552] <- 7
deidgroup$days[553] <- 15
deidgroup$days[554] <- 14
deidgroup$days[555] <- 0
deidgroup$days[556] <- 0
deidgroup$days[557] <- 0
deidgroup$days[558] <- 1
deidgroup$days[559] <- 0
deidgroup$days[560] <- 0
deidgroup$days[561] <- 1
deidgroup$days[562] <- 2
deidgroup$days[563] <- 0
deidgroup$days[564] <- 1
deidgroup$days[565] <- 1
deidgroup$days[566] <- NA
deidgroup$days[567] <- 3
deidgroup$days[568] <- 0
deidgroup$days[569] <- 0
deidgroup$days[570] <- 0
deidgroup$days[571] <- 0
deidgroup$days[572] <- 0
deidgroup$days[573] <- 0
deidgroup$days[574] <- 0
deidgroup$days[575] <- 14
deidgroup$days[576] <- 0
deidgroup$days[577] <- 0
deidgroup$days[578] <- 0
deidgroup$days[579] <- 0
deidgroup$days[580] <- 0
deidgroup$days[581] <- 1
deidgroup$days[582] <- 0
deidgroup$days[583] <- 0
deidgroup$days[584] <- 18
deidgroup$days[585] <- 0
deidgroup$days[586] <- 1
deidgroup$days[587] <- 4
deidgroup$days[588] <- 1
deidgroup$days[589] <- 0
deidgroup$days[590] <- 0
deidgroup$days[591] <- 0
deidgroup$days[592] <- 0
deidgroup$days[593] <- 0
deidgroup$days[594] <- 0
deidgroup$days[595] <- 0
deidgroup$days[596] <- 0
deidgroup$days[597] <- 0
deidgroup$days[598] <- 0
deidgroup$days[599] <- 0
deidgroup$days[600] <- 1
deidgroup$days[601] <- 8
deidgroup$days[602] <- 1
deidgroup$days[603] <- 1
deidgroup$days[604] <- 0
deidgroup$days[605] <- NA
deidgroup$days[606] <- NA
deidgroup$days[607] <- NA
deidgroup$days[608] <- NA
deidgroup$days[612] <- 2
deidgroup$days[615] <- 0
deidgroup$days[616] <- 0
deidgroup$days[617] <- 0
deidgroup$days[618] <- 0
deidgroup$days[619] <- 0
deidgroup$days[620] <- 1
deidgroup$days[621] <- 0
deidgroup$days[622] <- 0
deidgroup$days[623] <- NA
deidgroup$days[625] <- 0
deidgroup$days[626] <- 0
deidgroup$days[627] <- 0
deidgroup$days[628] <- 5
deidgroup$days[629] <- 1
deidgroup$days[631] <- 5
deidgroup$days[632] <- 0
deidgroup$days[633] <- 0
deidgroup$days[634] <- 1
deidgroup$days[635] <- 0
deidgroup$days[636] <- 0
deidgroup$days[637] <- 1
deidgroup$days[638] <- 0
deidgroup$days[639] <- 0
deidgroup$days[640] <- 0
deidgroup$days[641] <- 8
deidgroup$days[642] <- NA
deidgroup$days[643] <- NA
deidgroup$days[644] <- 0
deidgroup$days[649] <- 8
deidgroup$days[650] <- 13
deidgroup$days[651] <- 0
deidgroup$days[652] <- 1
deidgroup$days[653] <- 3
deidgroup$days[654] <- 1
deidgroup$days[655] <- 1
deidgroup$days[656] <- 0
deidgroup$days[657] <- 1
deidgroup$days[658] <- 1
deidgroup$days[659] <- 1
deidgroup$days[660] <- 0
deidgroup$days[661] <- NA
deidgroup$days[662] <- NA
deidgroup$days[663] <- NA
deidgroup$days[666] <- 0
deidgroup$days[670] <- 0
deidgroup$days[672] <- 0
deidgroup$days[674] <- 0
deidgroup$days[676] <- 12
deidgroup$days[677] <- 1
deidgroup$days[678] <- 0
deidgroup$days[679] <- 0
deidgroup$days[680] <- 3
deidgroup$days[681] <- 0
deidgroup$days[682] <- 2
deidgroup$days[683] <- 0
deidgroup$days[684] <- 0
deidgroup$days[685] <- 0
deidgroup$days[686] <- 2
deidgroup$days[687] <- 0
deidgroup$days[688] <- 0
deidgroup$days[689] <- 1
deidgroup$days[690] <- 0
deidgroup$days[691] <- 0
deidgroup$days[692] <- 0
deidgroup$days[693] <- 0
deidgroup$days[694] <- 1
deidgroup$days[695] <- 0
deidgroup$days[696] <- 3
deidgroup$days[697] <- 1
deidgroup$days[698] <- 0
deidgroup$days[699] <- 1
deidgroup$days[700] <- 1
deidgroup$days[701] <- 0
deidgroup$days[702] <- 1
deidgroup$days[703] <- 0
deidgroup$days[704] <- 1
deidgroup$days[705] <- 0
deidgroup$days[706] <- 1
deidgroup$days[707] <- 0
deidgroup$days[708] <- 1
deidgroup$days[709] <- 0
deidgroup$days[710] <- 1
deidgroup$days[711] <- 0
deidgroup$days[712] <- 0
deidgroup$days[713] <- 1
deidgroup$days[714] <- 1
deidgroup$days[713] <- 1
deidgroup$days[715] <- 0
deidgroup$days[716] <- 5
deidgroup$days[717] <- NA
deidgroup$days[718] <- NA
deidgroup$days[719] <- 1
deidgroup$days[721] <- 0
deidgroup$days[723] <- 0
deidgroup$days[724] <- 1
deidgroup$days[726] <- 0
deidgroup$days[727] <- 0
deidgroup$days[728] <- 0
deidgroup$days[729] <- 5
deidgroup$days[730] <- 0
deidgroup$days[731] <- 8
deidgroup$days[732] <- 0
deidgroup$days[733] <- 0
deidgroup$days[734] <- 0
deidgroup$days[735] <- 0
deidgroup$days[736] <- 0
deidgroup$days[737] <- 0
deidgroup$days[738] <- 0
deidgroup$days[739] <- 0
deidgroup$days[740] <- 1
deidgroup$days[741] <- 0
deidgroup$days[742] <- 0
deidgroup$days[743] <- 0
deidgroup$days[744] <- 0
deidgroup$days[745] <- 0
deidgroup$days[746] <- 0
deidgroup$days[747] <- 0
deidgroup$days[748] <- 0
deidgroup$days[749] <- 0
deidgroup$days[750] <- 0
deidgroup$days[751] <- 1
deidgroup$days[752] <- 0
deidgroup$days[753] <- 0
deidgroup$days[754] <- NA
deidgroup$days[755] <- 8
deidgroup$days[756] <- 0
deidgroup$days[757] <- 1
deidgroup$days[758] <- 0
deidgroup$days[759] <- 0
deidgroup$days[760] <- 2
deidgroup$days[761] <- NA
deidgroup$days[762] <- NA
deidgroup$days[763] <- 0
deidgroup$days[764] <- 0
deidgroup$days[767] <- 0
deidgroup$days[768] <- 0
deidgroup$days[770] <- 0
deidgroup$days[771] <- 3
deidgroup$days[772] <- 0
deidgroup$days[773] <- 4
deidgroup$days[774] <- 0
deidgroup$days[775] <- 8
deidgroup$days[776] <- 1
deidgroup$days[777] <- 0
deidgroup$days[778] <- 1
deidgroup$days[779] <- 0
deidgroup$days[780] <- 1
deidgroup$days[781] <- 2
deidgroup$days[782] <- 0
deidgroup$days[783] <- 1
deidgroup$days[784] <- 0
deidgroup$days[785] <- 0
deidgroup$days[786] <- 0
deidgroup$days[787] <- 0
deidgroup$days[788] <- 0
deidgroup$days[789] <- 0
deidgroup$days[790] <- 0
deidgroup$days[791] <- 0
deidgroup$days[792] <- 6
deidgroup$days[793] <- 0
deidgroup$days[794] <- 2
deidgroup$days[795] <- 0
deidgroup$days[796] <- 0
deidgroup$days[797] <- 0
deidgroup$days[798] <- 0
deidgroup$days[799] <- 0
deidgroup$days[800] <- 3
deidgroup$days[801] <- 5
deidgroup$days[802] <- 2
deidgroup$days[803] <- NA
deidgroup$days[806] <- 0
deidgroup$days[807] <- 0
deidgroup$days[808] <- 7
deidgroup$days[811] <- 0
deidgroup$days[812] <- 0
deidgroup$days[813] <- 2
deidgroup$days[814] <- 0
deidgroup$days[815] <- 3
deidgroup$days[816] <- 1
deidgroup$days[817] <- 0
deidgroup$days[818] <- 0
deidgroup$days[819] <- NA
deidgroup$days[820] <- 0
deidgroup$days[821] <- 6
deidgroup$days[822] <- NA
deidgroup$days[824] <- 0
deidgroup$days[827] <- 0
deidgroup$days[829] <- 13
deidgroup$days[830] <- 6
deidgroup$days[831] <- 1
deidgroup$days[832] <- 0
deidgroup$days[833] <- 0
deidgroup$days[834] <- 1
deidgroup$days[835] <- 0
deidgroup$days[836] <- 14
deidgroup$days[837] <- 0
deidgroup$days[838] <- 0
deidgroup$days[839] <- 0
deidgroup$days[840] <- 0
deidgroup$days[841] <- 3
deidgroup$days[842] <- 0
deidgroup$days[843] <- 0
deidgroup$days[844] <- NA
deidgroup$days[846] <- 0
deidgroup$days[849] <- 0
deidgroup$days[850] <- 0
deidgroup$days[851] <- 0
deidgroup$days[852] <- 0
deidgroup$days[853] <- 0
deidgroup$days[854] <- 0
deidgroup$days[855] <- 0
deidgroup$days[856] <- 0
deidgroup$days[857] <- 0
deidgroup$days[858] <- 0
deidgroup$days[859] <- 0
deidgroup$days[860] <- 0
deidgroup$days[861] <- 8
deidgroup$days[862] <- NA
deidgroup$days[863] <- NA
deidgroup$days[864] <- NA
deidgroup$days[865] <- 0
deidgroup$days[868] <- 0
deidgroup$days[869] <- 0
deidgroup$days[872] <- 0
deidgroup$days[873] <- 1
deidgroup$days[874] <- 4
deidgroup$days[875] <- 5
deidgroup$days[877] <- 4
deidgroup$days[879] <- 1
deidgroup$days[880] <- 0
deidgroup$days[881] <- 0
deidgroup$days[882] <- 6
deidgroup$days[883] <- 0
deidgroup$days[884] <- 5
deidgroup$days[885] <- 3
deidgroup$days[886] <- 1
deidgroup$days[887] <- 0
deidgroup$days[888] <- 1
deidgroup$days[889] <- 1
deidgroup$days[890] <- 0
deidgroup$days[891] <- 0
deidgroup$days[892] <- 3
deidgroup$days[893] <- 2
deidgroup$days[894] <- 0
deidgroup$days[895] <- 0
deidgroup$days[896] <- 2
deidgroup$days[897] <- 0
deidgroup$days[898] <- 0
deidgroup$days[899] <- 0
deidgroup$days[900] <- 2
deidgroup$days[901] <- 0
deidgroup$days[902] <- 0
deidgroup$days[903] <- 0
deidgroup$days[904] <- 6
deidgroup$days[905] <- 0
deidgroup$days[906] <- 0
deidgroup$days[907] <- 1
deidgroup$days[908] <- 0
deidgroup$days[909] <- 14
deidgroup$days[910] <- 0
deidgroup$days[911] <- 1
deidgroup$days[912] <- 0
deidgroup$days[913] <- 0
deidgroup$days[914] <- NA
deidgroup$days[916] <- 1
deidgroup$days[917] <- 0
deidgroup$days[918] <- 8
deidgroup$days[919] <- 1
deidgroup$days[920] <- 7
deidgroup$days[923] <- 0
deidgroup$days[924] <- 1
deidgroup$days[925] <- 0
deidgroup$days[927] <- 0
deidgroup$days[928] <- 0
deidgroup$days[929] <- 5
deidgroup$days[930] <- 0
deidgroup$days[931] <- 0
deidgroup$days[932] <- 18
deidgroup$days[933] <- 0
deidgroup$days[934] <- 1
deidgroup$days[935] <- 0
deidgroup$days[936] <- 2
deidgroup$days[937] <- 1
deidgroup$days[938] <- 0
deidgroup$days[939] <- 1
deidgroup$days[940] <- NA
deidgroup$days[941] <- 1
deidgroup$days[942] <- 0
deidgroup$days[943] <- 0
deidgroup$days[944] <- 0
deidgroup$days[945] <- 0
deidgroup$days[946] <- 0
deidgroup$days[947] <- NA
deidgroup$days[948] <- 1
deidgroup$days[949] <- 1
deidgroup$days[950] <- 1
deidgroup$days[951] <- 1
deidgroup$days[952] <- 3
deidgroup$days[953] <- 0
deidgroup$days[954] <- 0
deidgroup$days[955] <- 0
deidgroup$days[956] <- 0
deidgroup$days[957] <- 0
deidgroup$days[958] <- 1
deidgroup$days[959] <- 1
deidgroup$days[960] <- 0
deidgroup$days[961] <- 0
deidgroup$days[962] <- 0
deidgroup$days[963] <- 0
deidgroup$days[964] <- NA
deidgroup$days[965] <- 0
deidgroup$days[979] <- 6
deidgroup$days[980] <- 7
deidgroup$days[981] <- 7
deidgroup$days[982] <- 5
deidgroup$days[983] <- 7
deidgroup$days[984] <- 11
deidgroup$days[985] <- 5
deidgroup$days[986] <- 1
deidgroup$days[987] <- 0
deidgroup$days[988] <- 3
deidgroup$days[989] <- 0
deidgroup$days[990] <- 0
deidgroup$days[991] <- 0
deidgroup$days[992] <- 0
deidgroup$days[993] <- 1
deidgroup$days[994] <- 0
deidgroup$days[995] <- 0
deidgroup$days[996] <- 0
deidgroup$days[997] <- 4
deidgroup$days[998] <- 0
deidgroup$days[999] <- 0
deidgroup$days[1000] <- 1
deidgroup$days[1001] <- 0
deidgroup$days[1002] <- 0
deidgroup$days[1003] <- 0 
deidgroup$days[1004] <- 0
deidgroup$days[1005] <- 1
deidgroup$days[1006] <- 2
deidgroup$days[1007] <- 0
deidgroup$days[1008] <- 0
deidgroup$days[1009] <- 0 
deidgroup$days[1010] <- 2
deidgroup$days[1011] <- 0
deidgroup$days[1012] <- NA
deidgroup$days[1013] <- NA
deidgroup$days[1014] <- NA
deidgroup$days[1015] <- NA 
deidgroup$days[1016] <- NA
deidgroup$days[1021] <- 0 
deidgroup$days[1022] <- 0
deidgroup$days[1027] <- 0 
deidgroup$days[1028] <- 2
deidgroup$days[1029] <- 0
deidgroup$days[1030] <- 0
deidgroup$days[1035] <- 0
deidgroup$days[1036] <- 0
deidgroup$days[1037] <- 3
deidgroup$days[1038] <- 0
deidgroup$days[1040] <- 0
deidgroup$days[1041] <- 0
deidgroup$days[1047] <- 5
deidgroup$days[1048] <- 0
deidgroup$days[1049] <- 0
deidgroup$days[1050] <- 0
deidgroup$days[1051] <- 2
deidgroup$days[1052] <- 0
deidgroup$days[1053] <- 0
deidgroup$days[1059] <- 14
deidgroup$days[1060] <- 2
deidgroup$days[1061] <- 0
deidgroup$days[1062] <- 3
deidgroup$days[1063] <- 1
deidgroup$days[1064] <- 0
deidgroup$days[1066] <- 0
deidgroup$days[1068] <- 1
deidgroup$days[1069] <- 0
deidgroup$days[1070] <- 1
deidgroup$days[1071] <- 2
deidgroup$days[1072] <- NA
deidgroup$days[1078] <- 0
deidgroup$days[1079] <- 0
deidgroup$days[1080] <- 0
deidgroup$days[1081] <- 0
deidgroup$days[1082] <- 0
deidgroup$days[1083] <- 2  
deidgroup$days[1084] <- 0
deidgroup$days[1085] <- 0
deidgroup$days[1086] <- 3
deidgroup$days[1094] <- 0
deidgroup$days[1095] <- 1
deidgroup$days[1096] <- 1
deidgroup$days[1097] <- 3
deidgroup$days[1098] <- 0
deidgroup$days[1099] <- 0
deidgroup$days[1100] <- NA
deidgroup$days[1110] <- 1
deidgroup$days[1111] <- 0 
deidgroup$days[1113] <- 0
deidgroup$days[1114] <- 0
deidgroup$days[1115] <- 0
deidgroup$days[1116] <- NA
deidgroup$days[1117] <- NA
deidgroup$days[1131] <- 7
deidgroup$days[1132] <- 1
deidgroup$days[1133] <- 0
deidgroup$days[1134] <- 3
deidgroup$days[1135] <- 1
deidgroup$days[1136] <- 2
deidgroup$days[1137] <- 0
deidgroup$days[1138] <- 0
deidgroup$days[1139] <- 1
deidgroup$days[1140] <- 1
deidgroup$days[1141] <- 0
deidgroup$days[1142] <- 3
deidgroup$days[1143] <- 0
deidgroup$days[1144] <- 0
deidgroup$days[1145] <- 0
deidgroup$days[1146] <- 0
deidgroup$days[1148] <- NA
deidgroup$days[1153] <- 0
deidgroup$days[1155] <- 0
deidgroup$days[1156] <- 1
deidgroup$days[1157] <- 0
deidgroup$days[1158] <- 0
deidgroup$days[1159] <- 0
deidgroup$days[1160] <- 0
deidgroup$days[1161] <- 0
deidgroup$days[1162] <- NA
deidgroup$days[1167] <- 0
deidgroup$days[1168] <- 0
deidgroup$days[1169] <- 0
deidgroup$days[1170] <- 0
deidgroup$days[1171] <- NA
deidgroup$days[1179] <- 0
deidgroup$days[1180] <- 0
deidgroup$days[1181] <- 0
deidgroup$days[1182] <- 0
deidgroup$days[1183] <- 0
deidgroup$days[1197] <- 8
deidgroup$days[1198] <- 7
deidgroup$days[1199] <- 10
deidgroup$days[1200] <- 11
deidgroup$days[1201] <- 3
deidgroup$days[1202] <- 0
deidgroup$days[1203] <- 0
deidgroup$days[1204] <- 2
deidgroup$days[1205] <- 0
deidgroup$days[1206] <- 3
deidgroup$days[1207] <- 0
deidgroup$days[1208] <- 1
deidgroup$days[1209] <- 0
deidgroup$days[1210] <- 0
deidgroup$days[1211] <- 3
deidgroup$days[1212] <- 1
deidgroup$days[1213] <- 1
deidgroup$days[1214] <- 0
deidgroup$days[1215] <- 0
deidgroup$days[1216] <- 0
deidgroup$days[1217] <- 1
deidgroup$days[1218] <- 0
deidgroup$days[1219] <- 0
deidgroup$days[1220] <- 1
deidgroup$days[1221] <- 0
deidgroup$days[1222] <- 2
deidgroup$days[1223] <- 1
deidgroup$days[1224] <- 0
deidgroup$days[1225] <- NA
deidgroup$days[1253] <- 6
deidgroup$days[1254] <- 0  
deidgroup$days[1255] <- 1
deidgroup$days[1256] <- 0
deidgroup$days[1257] <- 1
deidgroup$days[1258] <- 0
deidgroup$days[1259] <- 1
deidgroup$days[1260] <- 1
deidgroup$days[1261] <- 0
deidgroup$days[1262] <- 0
deidgroup$days[1263] <- 0
deidgroup$days[1264] <- 1
deidgroup$days[1265] <- 0
deidgroup$days[1266] <- 0
deidgroup$days[1267] <- 0
deidgroup$days[1268] <- 0
deidgroup$days[1269] <- 0
deidgroup$days[1270] <- 1
deidgroup$days[1271] <- 2
deidgroup$days[1272] <- 0
deidgroup$days[1273] <- 0
deidgroup$days[1274] <- 1
deidgroup$days[1275] <- 1
deidgroup$days[1276] <- 0
deidgroup$days[1277] <- NA
deidgroup$days[1291] <- 0
deidgroup$days[1292] <- 1
deidgroup$days[1293] <- 1
deidgroup$days[1294] <- 0
deidgroup$days[1295] <- 1
deidgroup$days[1296] <- 0
deidgroup$days[1297] <- 0
deidgroup$days[1298] <- 0
deidgroup$days[1299] <- 0
deidgroup$days[1300] <- 0
deidgroup$days[1301] <- 0
deidgroup$days[1302] <- 0
deidgroup$days[1304] <- 0
deidgroup$days[1305] <- 0
deidgroup$days[1306] <- 1
deidgroup$days[1307] <- 0
deidgroup$days[1308] <- 3
deidgroup$days[1309] <- 1
deidgroup$days[1310] <- 0
deidgroup$days[1311] <- 0
deidgroup$days[1312] <- 1
deidgroup$days[1313] <- 1
deidgroup$days[1314] <- 1
deidgroup$days[1315] <- 0
deidgroup$days[1316] <- 0
deidgroup$days[1318] <- NA
deidgroup$days[1319] <- NA
deidgroup$days[1324] <- 0
deidgroup$days[1325] <- NA
deidgroup$days[1328] <- 1
deidgroup$days[1329] <- 0
deidgroup$days[1330] <- 1
deidgroup$days[1331] <- 0
deidgroup$days[1332] <- NA
deidgroup$days[1335] <- 1
deidgroup$days[1336] <- 0
deidgroup$days[1337] <- 0
deidgroup$days[1338] <- 0
deidgroup$days[1343] <- 7
deidgroup$days[1344] <- 5
deidgroup$days[1345] <- 5
deidgroup$days[1346] <- 8
deidgroup$days[1347] <- 0
deidgroup$days[1348] <- 0
deidgroup$days[1349] <- 0
deidgroup$days[1350] <- 0
deidgroup$days[1351] <- 0
deidgroup$days[1352] <- 0
deidgroup$days[1353] <- 1
deidgroup$days[1354] <- 1
deidgroup$days[1359] <- 6
deidgroup$days[1360] <- 9
deidgroup$days[1361] <- 0
deidgroup$days[1362] <- 1
deidgroup$days[1363] <- 0
deidgroup$days[1364] <- 0
deidgroup$days[1365] <- 1
deidgroup$days[1366] <- 1
deidgroup$days[1367] <- 0
deidgroup$days[1368] <- 3
deidgroup$days[1369] <- 0
deidgroup$days[1370] <- 0
deidgroup$days[1371] <- 0
deidgroup$days[1372] <- NA
deidgroup$days[1380] <- 6
deidgroup$days[1381] <- 0
deidgroup$days[1382] <- 0
deidgroup$days[1383] <- 1
deidgroup$days[1385] <- 0
deidgroup$days[1386] <- 0
deidgroup$days[1387] <- 0
deidgroup$days[1388] <- 0
deidgroup$days[1389] <- 0
deidgroup$days[1390] <- 0
deidgroup$days[1391] <- NA
deidgroup$days[1393] <- 6
deidgroup$days[1394] <- 0
deidgroup$days[1395] <- 3
deidgroup$days[1396] <- 0
deidgroup$days[1397] <- NA
deidgroup$days[1399] <- 0
deidgroup$days[1400] <- 0
deidgroup$days[1403] <- 1
deidgroup$days[1404] <- 0
deidgroup$days[1405] <- 0
deidgroup$days[1415] <- 5
deidgroup$days[1416] <- 0
deidgroup$days[1417] <- 0
deidgroup$days[1419] <- 1
deidgroup$days[1420] <- 1
deidgroup$days[1421] <- 0
deidgroup$days[1422] <- 0
deidgroup$days[1423] <- 0
deidgroup$days[1424] <- 0
deidgroup$days[1425] <- 0
deidgroup$days[1426] <- 0
deidgroup$days[1427] <- 1
deidgroup$days[1428] <- 0
deidgroup$days[1429] <- 1
deidgroup$days[1430] <- 0
deidgroup$days[1433] <- 5
deidgroup$days[1434] <- 0
deidgroup$days[1435] <- 0
deidgroup$days[1436] <- 2
deidgroup$days[1437] <- 1
deidgroup$days[1438] <- 0
deidgroup$days[1439] <- 2
deidgroup$days[1440] <- 0
deidgroup$days[1441] <- 0
deidgroup$days[1442] <- 0
deidgroup$days[1443] <- 0
deidgroup$days[1444] <- 2
deidgroup$days[1445] <- 0
deidgroup$days[1446] <- NA
deidgroup$days[1456] <- 0
deidgroup$days[1457] <- 0
deidgroup$days[1458] <- 0
deidgroup$days[1459] <- 2
deidgroup$days[1460] <- 2
deidgroup$days[1461] <- 0
deidgroup$days[1462] <- 1
deidgroup$days[1463] <- 0
deidgroup$days[1464] <- 2  
deidgroup$days[1465] <- 1
deidgroup$days[1467] <- 0
deidgroup$days[1468] <- 3  
deidgroup$days[1469] <- 6
deidgroup$days[1470] <- 0

# Ensuring Emails that Recieved No Reply at all Are Coded as 31 days and Not Substantive
deidgroup[, 20][deidgroup[, 14] == 0] <- 31
deidgroup[, 19][deidgroup[, 14] == 0] <- 0

# Creating College County and Percent Trump Vote at County Level Variables
deidgroup$county <- NA
deidgroup$trumpvote <-NA

# Filling in County and Trump Vote at County Level
deidgroup$county[1] <- "Floyd_GA"
deidgroup$trumpvote[1] <- 70.2
deidgroup$county[2] <- "Okaloosa_FL"
deidgroup$trumpvote[2] <- 71.3
deidgroup$county[3] <- "Emanuel_GA"
deidgroup$trumpvote[3] <- 68
deidgroup$county[4] <- "Rockbridge_VA"
deidgroup$trumpvote[4] <- 62.4
deidgroup$county[5] <- "Volusia_FL"
deidgroup$trumpvote[5] <- 54.8
deidgroup$county[6] <- "Wood_WV"
deidgroup$trumpvote[6] <- 71.4
deidgroup$county[7] <- "Drew_AR"
deidgroup$trumpvote[7] <- 60.2
deidgroup$county[8] <- "Columbia_FL"
deidgroup$trumpvote[8] <- 70.9
deidgroup$county[9] <- "Jackson_FL"
deidgroup$trumpvote[9] <- 67.8
deidgroup$county[10] <- "Palm_Beach_FL"
deidgroup$trumpvote[10] <- 41.2
deidgroup$county[11] <- "Fulton_GA"
deidgroup$trumpvote[11] <- 27.1
deidgroup$county[12] <- "Orange_FL"
deidgroup$trumpvote[12] <- 35.7
deidgroup$county[13] <- "Randolph_WV"
deidgroup$trumpvote[13] <- 70.1
deidgroup$county[14] <- "Pinellas_FL"
deidgroup$trumpvote[14] <- 48.6
deidgroup$county[15] <- "Lake_FL"
deidgroup$trumpvote[15] <- 60
deidgroup$county[16] <- "Duval_FL"
deidgroup$trumpvote[16] <- 49
deidgroup$county[17] <- "Miami-Dade_FL"
deidgroup$trumpvote[17] <- 34.1
deidgroup$county[18] <- "Forsyth_NC"
deidgroup$trumpvote[18] <- 43.4
deidgroup$county[19] <- "Pinellas_FL"
deidgroup$trumpvote[19] <- 48.6
deidgroup$county[20] <- "Alachua_FL"
deidgroup$trumpvote[20] <- 36.4
deidgroup$county[21] <- "Jefferson_KY"
deidgroup$trumpvote[21] <- 41.7
deidgroup$county[22] <- "Manatee_FL"
deidgroup$trumpvote[22] <- 57
deidgroup$county[23] <- "Wake_NC"
deidgroup$trumpvote[23] <- 37.9
deidgroup$county[24] <- "Whitfield_GA"
deidgroup$trumpvote[24] <- 70.9
deidgroup$county[25] <- "Jefferson_KY"
deidgroup$trumpvote[25] <- 41.7
deidgroup$county[26] <- "San_Diego_CA"
deidgroup$trumpvote[26] <- 38.2
deidgroup$county[27] <- "Rio_Arriba_NM"
deidgroup$trumpvote[27] <- 24.2
deidgroup$county[28] <- "Wood_WI"
deidgroup$trumpvote[28] <- 57
deidgroup$county[29] <- "Suffolk_MA"
deidgroup$trumpvote[29] <- 16.5
deidgroup$county[30] <- "Clark_NV"
deidgroup$trumpvote[30] <- 41.8
deidgroup$county[31] <- "King_WA"
deidgroup$trumpvote[31] <- 21.7
deidgroup$county[32] <- "Cook_IL"
deidgroup$trumpvote[32] <- 21.4
deidgroup$county[33] <- "San_Francisco_CA"
deidgroup$trumpvote[33] <- 9.4
deidgroup$county[34] <- "Cook_IL"
deidgroup$trumpvote[34] <- 21.4
deidgroup$county[35] <- "Alamosa_CO"
deidgroup$trumpvote[35] <- 43.9
deidgroup$county[36] <- "Carson_City_NV"
deidgroup$trumpvote[36] <- 52.5
deidgroup$county[37] <- "Clallam_WA"
deidgroup$trumpvote[37] <- 47.6
deidgroup$county[38] <- NA
deidgroup$trumpvote[38] <- NA 
deidgroup$county[39] <- "Allen_OH"
deidgroup$trumpvote[39] <- 66.9
deidgroup$county[40] <- "Hamilton_OH"
deidgroup$trumpvote[40] <- 43
deidgroup$county[41] <- "Cook_IL"
deidgroup$trumpvote[41] <- 21.4
deidgroup$county[42] <- "Ventura_CA"
deidgroup$trumpvote[42] <- 38.6
deidgroup$county[43] <- "Multnomah_OR"
deidgroup$trumpvote[43] <- 17.6
deidgroup$county[44] <- "Champaign_OH"
deidgroup$trumpvote[34] <- 70
deidgroup$county[45] <- "Hidalgo_TX"
deidgroup$trumpvote[45] <- 28.1
deidgroup$county[46] <- "New_London_CT"
deidgroup$trumpvote[46] <- 43.8
deidgroup$county[47] <- "Elko_NV"
deidgroup$trumpvote[47] <- 73
deidgroup$county[48] <- "Maui_HI"
deidgroup$trumpvote[48] <- 26.2
deidgroup$county[49] <- "Marion_IN"
deidgroup$trumpvote[49] <- 36.1
deidgroup$county[50] <- "Suffolk_MA"
deidgroup$trumpvote[50] <- 16.5
deidgroup$county[51] <- "Garfield_CO"
deidgroup$trumpvote[51] <- 49.6
deidgroup$county[52] <- "Lewis_WA"
deidgroup$trumpvote[52] <- 65.1
deidgroup$county[53] <- "St_Louis_MO"
deidgroup$trumpvote[53] <- 39.5
deidgroup$county[54] <- "Alaska"
deidgroup$trumpvote[54] <- 51.28
deidgroup$county[55] <- "Kern_CA"
deidgroup$trumpvote[55] <- 54.7
deidgroup$county[56] <- "Dallas_TX"
deidgroup$trumpvote[56] <- 34.9
deidgroup$county[57] <- "Hillsborough_NH"
deidgroup$trumpvote[57] <- 47.4
deidgroup$county[58] <- "Kane_IL"
deidgroup$trumpvote[58] <- 42.4
deidgroup$county[59] <- "Windham_VT"
deidgroup$trumpvote[59] <- 25.8
deidgroup$county[60] <- "Logan_IL"
deidgroup$trumpvote[60] <- 67.3
deidgroup$county[61] <- "San_Diego_CA"
deidgroup$trumpvote[61] <- 38.2
deidgroup$county[62] <- "Grand Traverse_MI"
deidgroup$trumpvote[62] <-  53.3
deidgroup$county[63] <- "Jefferson_IA"
deidgroup$trumpvote[63] <- 46.7
deidgroup$county[64] <- "Kitsap_WA"
deidgroup$trumpvote[64] <- 39.4
deidgroup$county[65] <- NA
deidgroup$trumpvote[65] <- NA 
deidgroup$county[66] <- "Hidalgo_TX"
deidgroup$trumpvote[66] <- 28.1
deidgroup$trumpvote[67] <- "Athens_OH"
deidgroup$county[67] <- 38.7
deidgroup$trumpvote[68] <- "Erie_NY"
deidgroup$county[68] <- 45.4
deidgroup$trumpvote[69] <- "King_WA"
deidgroup$county[69] <- 21.7
deidgroup$trumpvote[70] <- "Nemaha_NE"
deidgroup$county[70] <- 68.1
deidgroup$trumpvote[71] <- "Franklin_WA"
deidgroup$county[71] <- 55.2
deidgroup$trumpvote[72] <- "Sarpy_NE"
deidgroup$county[72] <- 57.4
deidgroup$trumpvote[73] <- "Yakima_WA"
deidgroup$county[73] <- 54.8
deidgroup$trumpvote[74] <- "Maricopa_AZ" 
deidgroup$county[74] <- 49.1
deidgroup$trumpvote[75] <- "Lyon_MN"
deidgroup$county[75] <- 59.8
deidgroup$trumpvote[76] <- "San Joaquin_CA"
deidgroup$county[76] <- 41
deidgroup$trumpvote[77] <- "Los Angeles_CA"  
deidgroup$county[77] <- 23.4
deidgroup$trumpvote[78] <- "Salt Lake_UT"
deidgroup$county[78] <- 32.6
deidgroup$trumpvote[79] <- "Middlesex_MA"
deidgroup$county[79] <- 28.2
deidgroup$trumpvote[80] <- "Grant_NM"
deidgroup$county[80] <- 41.3
deidgroup$trumpvote[81] <- "King_WA"
deidgroup$county[81] <- 21.7
deidgroup$county[82] <- "Dawes_NE"
deidgroup$trumpvote[82] <- 71.5
deidgroup$county[83] <- "Hampshire_MA"
deidgroup$trumpvote[83] <- 26.8
deidgroup$county[84] <- "Erie_NY"
deidgroup$trumpvote[84] <- 45.4
deidgroup$county[85] <- "Jackson_MI"
deidgroup$trumpvote[85] <- 57.2
deidgroup$county[86] <- "Bannock_ID"
deidgroup$trumpvote[86] <- 51.4
deidgroup$county[87] <- "Hill_MT"
deidgroup$trumpvote[87] <- 54.1
deidgroup$county[88] <- "Rapides_LA"
deidgroup$trumpvote[88] <- 64.8
deidgroup$county[89] <- "Sumter_GA"
deidgroup$trumpvote[89] <- 48.1
deidgroup$county[90] <- "Wayne_NC"
deidgroup$trumpvote[90] <- 54.9
deidgroup$county[91] <- "Lincoln_LA"
deidgroup$trumpvote[91] <-  57.7
deidgroup$county[92] <- "Avery_NC"
deidgroup$trumpvote[92] <- 77.2
deidgroup$county[93] <- "Madison_KY"
deidgroup$trumpvote[93] <- 62.8
deidgroup$county[94] <- "Clark_AR"
deidgroup$trumpvote[94] <- 51.7
deidgroup$county[95] <- "Weakley_TN"
deidgroup$trumpvote[95] <- 74.2
deidgroup$county[96] <- "Calhoun_AL"
deidgroup$trumpvote[96] <- 69.2
deidgroup$county[97] <- "Ohio_WV"
deidgroup$trumpvote[97] <- 62.2
deidgroup$county[98] <- "Pasquotank_NC"
deidgroup$trumpvote[98] <- 47.6
deidgroup$county[99] <- "Jefferson_WV"
deidgroup$trumpvote[99] <- 54.8
deidgroup$county[100] <- "Wise_VA"
deidgroup$trumpvote[100] <- 79.9
deidgroup$county[101] <- "Montgomery_VA"
deidgroup$trumpvote[101] <- 45.6
deidgroup$county[102] <- "Bolivar_MS"
deidgroup$trumpvote[102] <- 33.1
deidgroup$county[103] <- "Gilmer_WV"
deidgroup$trumpvote[103] <- 74.7
deidgroup$county[104] <- "Franklin_VA"
deidgroup$trumpvote[104] <- 69.2
deidgroup$county[105] <- "Carroll_GA"
deidgroup$trumpvote[105] <- 68.5
deidgroup$county[106] <-  "Jackson_NC"
deidgroup$trumpvote[106] <- 53.9
deidgroup$county[107] <- "Peach_GA"
deidgroup$trumpvote[107] <- 50.5
deidgroup$county[108] <- "Robeson_NC"
deidgroup$trumpvote[108] <- 51.4
deidgroup$county[109] <- "Pope_AR"
deidgroup$trumpvote[109] <- 72.1
deidgroup$county[110] <- "Darlington_SC"
deidgroup$trumpvote[110] <- 50.5
deidgroup$county[111] <- "Prince Edward_VA"
deidgroup$trumpvote[111] <- 45
deidgroup$county[112] <- "Florence_SC"
deidgroup$trumpvote[112] <- 51.1
deidgroup$county[113] <- "Polk_FL"
deidgroup$trumpvote[113] <- 55.4
deidgroup$county[114] <- "Mercer_WV"
deidgroup$trumpvote[114] <- 75.8
deidgroup$county[115] <- "Jefferson_WV"
deidgroup$trumpvote[115] <- 54.8
deidgroup$county[116] <- "Rockingham_VA"
deidgroup$trumpvote[116] <- 69.2
deidgroup$county[117] <- "Tangipahoa_LA"
deidgroup$trumpvote[117] <- 64.8
deidgroup$county[118] <- "Rowan_KY"
deidgroup$trumpvote[118] <- 58.5
deidgroup$county[119] <- "Bulloch_GA"
deidgroup$trumpvote[119] <- 59.9
deidgroup$county[120] <- "Lowndes_MS"
deidgroup$trumpvote[120] <- 52.2
deidgroup$county[121] <- "Shelby_MS"
deidgroup$trumpvote[121] <- 73.4
deidgroup$county[122] <- "Leflore_MS"
deidgroup$trumpvote[122] <- 28.8
deidgroup$county[123] <- "Transylvania_NC"
deidgroup$trumpvote[123] <- 59.9
deidgroup$county[124] <- "Thomas_GA"
deidgroup$trumpvote[124] <- 59.9
deidgroup$county[125] <- "Tift_GA"
deidgroup$trumpvote[125] <- 67.8
deidgroup$county[126] <- "Lafayette_MS"
deidgroup$trumpvote[126] <- 55.4
deidgroup$county[127] <- "Mercer_WV"
deidgroup$trumpvote[127] <- 75.8
deidgroup$county[128] <- "Prince Edward_VA"
deidgroup$trumpvote[128] <- 45
deidgroup$county[129] <- "Natchitoches_LA"
deidgroup$trumpvote[129] <- 54
deidgroup$county[130] <- "Madison_KY"
deidgroup$trumpvote[130] <- 62.8
deidgroup$county[131] <- "Putnam_TN"
deidgroup$trumpvote[131] <- 70.4
deidgroup$county[132] <- "Columbia_AR"
deidgroup$trumpvote[132] <- 61.4
deidgroup$county[133] <- "Lincoln_LA"
deidgroup$trumpvote[133] <- 57.7
deidgroup$county[134] <- "Lamar_GA"
deidgroup$trumpvote[134] <- 68.4
deidgroup$county[135] <- "Macon_AL"
deidgroup$trumpvote[135] <- 15.9
deidgroup$county[136] <- "Watauga_NC"
deidgroup$trumpvote[136] <- 47
deidgroup$county[137] <- "Coffee_GA"
deidgroup$trumpvote[137] <- 68.9
deidgroup$county[138] <- "Lafourche_LA"
deidgroup$trumpvote[138] <- 76.7
deidgroup$county[139] <- "Claiborne_MS"
deidgroup$trumpvote[139] <- 14
deidgroup$county[140] <- "Highlands_FL"
deidgroup$trumpvote[140] <- 64.7
deidgroup$county[141] <- "Cleveland_NC"
deidgroup$trumpvote[141] <- 64.3
deidgroup$county[142] <- "Habersham_GA"
deidgroup$trumpvote[142] <- 81.7
deidgroup$county[143] <- "Oktibbeha_MS"
deidgroup$trumpvote[143] <- 47.5
deidgroup$county[144] <- "Sumter_AL"
deidgroup$trumpvote[144] <- 24.7
deidgroup$county[145] <- "Calloway_KY"
deidgroup$trumpvote[145] <- 64.6
deidgroup$county[146] <- "seneca_OH"
deidgroup$trumpvote[146] <- 62
deidgroup$county[147] <- "Knox_OH"
deidgroup$trumpvote[147] <- 66.9
deidgroup$county[148] <- "Schoharie_NY"
deidgroup$trumpvote[148] <- 64.5
deidgroup$county[149] <- "Windsor_VT"
deidgroup$trumpvote[149] <- 30.9
deidgroup$county[150] <- "St. Mary's_MD"
deidgroup$trumpvote[150] <- 59.5
deidgroup$county[151] <- "Wyoming_PA"
deidgroup$trumpvote[151] <- 67.4
deidgroup$county[152] <- "Silver Bow_MT"
deidgroup$trumpvote[152] <- 38.6
deidgroup$county[153] <- "Buena Vista_IA"
deidgroup$trumpvote[153] <- 59.8
deidgroup$county[154] <- "Clarion_PA"
deidgroup$trumpvote[154] <- 71.8
deidgroup$county[155] <- "Roosevelt_NM"
deidgroup$trumpvote[155] <- 65.4
deidgroup$county[156] <- "Delaware_NY" 
deidgroup$trumpvote[156] <- 61.9
deidgroup$county[157] <- "Butler_PA"
deidgroup$trumpvote[157] <- 66.7
deidgroup$county[158] <- "St. Lawrence_NY"
deidgroup$trumpvote[158] <- 52.5
deidgroup$county[159] <- "Butte_CA"
deidgroup$trumpvote[159] <- 48
deidgroup$county[160] <- "Barnes_ND"
deidgroup$trumpvote[160] <- 60.1
deidgroup$county[161] <- "Lamoille_VT"
deidgroup$trumpvote[161] <- 30.7
deidgroup$county[162] <- "St. Lawrence_NY"
deidgroup$trumpvote[162] <- 52.5
deidgroup$county[163] <- "Washington_VT"
deidgroup$trumpvote[163] <- 27.9
deidgroup$county[164] <- "Lawrence_SD"
deidgroup$trumpvote[164] <- 62.6
deidgroup$county[165] <- "Rice_MN"
deidgroup$trumpvote[165] <- 47.9
deidgroup$county[166] <- "Nacogdoches_TX"
deidgroup$trumpvote[166] <- 65.8
deidgroup$county[167] <- "La Plata_CO"
deidgroup$trumpvote[167] <- 40.6
deidgroup$county[168] <- "Greene_OH"
deidgroup$trumpvote[168] <- 59.7
deidgroup$county[169] <- "Orange_VT"
deidgroup$trumpvote[169] <- 37.1
deidgroup$county[170] <- "Socorro_NM"
deidgroup$trumpvote[170] <- 38.2
deidgroup$county[171] <- "Polk_MN"
deidgroup$trumpvote[171] <- 61.1
deidgroup$county[172] <- "Otsego_NY"
deidgroup$trumpvote[172] <- 53.4
deidgroup$county[173] <- "Kennebec_ME"
deidgroup$trumpvote[173] <- 48.1
deidgroup$county[174] <- "Berkshire_MA"
deidgroup$trumpvote[174] <- 26
deidgroup$county[175] <- "Berkshire_MA"
deidgroup$trumpvote[175] <- 26
deidgroup$county[176] <- "Wicomico_MD"
deidgroup$trumpvote[176] <- 53.8
deidgroup$county[177] <- "Dutchess_NY"
deidgroup$trumpvote[177] <- 48.4
deidgroup$county[178] <- "Addison_VT"
deidgroup$trumpvote[178] <- 30.1
deidgroup$county[179] <- "St. Lawrence_NY"
deidgroup$trumpvote[179] <- 52.5
deidgroup$county[180] <- "Poweshiek_IA"
deidgroup$trumpvote[180] <- 50.9
deidgroup$county[181] <- "Lyon_KS"
deidgroup$trumpvote[181] <- 54.1
deidgroup$county[182] <- "Beltrami_MN"
deidgroup$trumpvote[182] <- 50.6
deidgroup$county[183] <- "Ashland_WI"
deidgroup$trumpvote[183] <- 43.3
deidgroup$county[184] <- "Wayne_NE"
deidgroup$trumpvote[184] <- 71.5
deidgroup$county[185] <- "Chester_PA"
deidgroup$trumpvote[185] <- 43.3
deidgroup$county[186] <- "Jefferson_IN"
deidgroup$trumpvote[186] <- 63.4
deidgroup$county[187] <- "San Miguel_NM"
deidgroup$trumpvote[187] <- 21.5
deidgroup$county[188] <- "Indiana_PA"
deidgroup$trumpvote[188] <- 66.1
deidgroup$county[189] <- "Franklin_NY"
deidgroup$trumpvote[189] <- 50.4
deidgroup$county[190] <- "Hunt_TX"
deidgroup$trumpvote[190] <- 76.5
deidgroup$county[191] <- "Brookings_SD"
deidgroup$trumpvote[191] <- 53.2
deidgroup$county[192] <- "Rutland_VT"
deidgroup$trumpvote[192] <- 45.1
deidgroup$county[193] <- "Steuben_IN"
deidgroup$trumpvote[193] <- 69.7
deidgroup$county[194] <- "Madison_NY"
deidgroup$trumpvote[194] <- 54.4
deidgroup$county[195] <- "Berkshire_MA"
deidgroup$trumpvote[195] <- 26
deidgroup$county[196] <- "Linn_IA"
deidgroup$trumpvote[196] <- 42
deidgroup$county[197] <- "Ellis_KS"
deidgroup$trumpvote[197] <- 71.3
deidgroup$county[198] <- "Grafton_NH"
deidgroup$trumpvote[198] <- 37.9
deidgroup$county[199] <- "Spokane_WA"
deidgroup$trumpvote[199] <- 49.9
deidgroup$county[200] <- "Franklin_PA"
deidgroup$trumpvote[200] <- 71.5
deidgroup$county[201] <- "Bowie_TX"
deidgroup$trumpvote[201] <- 72.3
deidgroup$county[202] <- "Klamath_OR"
deidgroup$trumpvote[202] <- 69
deidgroup$county[203] <- "Penobscot_MA"
deidgroup$trumpvote[203] <- 51.9
deidgroup$county[204] <- "Livingston_NY"
deidgroup$trumpvote[204] <- 61.3
deidgroup$county[205] <- "Hancock_ME"
deidgroup$trumpvote[205] <- 42.8
deidgroup$county[206] <- "Tompkins_NY"
deidgroup$trumpvote[206] <- 25.6
deidgroup$county[207] <- "Chippewa_MI"
deidgroup$trumpvote[207] <- 59.1
deidgroup$county[208] <- "Washoe_NV"
deidgroup$trumpvote[208] <- 45.2
deidgroup$county[209] <- "Merrimack_NH"
deidgroup$trumpvote[209] <- 45.9
deidgroup$county[210] <- "Logan_OK"
deidgroup$trumpvote[210] <- 71.8
deidgroup$county[211] <- "Grafton_NH"
deidgroup$trumpvote[211] <- 37.9
deidgroup$county[212] <- "Kent_MD"
deidgroup$trumpvote[212] <- 50.2
deidgroup$county[213] <- "Gunnison_CO"
deidgroup$trumpvote[213] <- 34.9
deidgroup$county[214] <- "Clay_SD"
deidgroup$trumpvote[214] <- 41.6
deidgroup$county[215] <- "Lake_SD"
deidgroup$trumpvote[215] <- 59.5
deidgroup$county[216] <- "Cattaraugus_NY"
deidgroup$trumpvote[216] <- 64.5
deidgroup$county[217] <- "Barnstable_MA"
deidgroup$trumpvote[217] <- 40.6
deidgroup$county[218] <- "Huntingdon_PA"
deidgroup$trumpvote[218] <- 73.7
deidgroup$county[219] <- "Vernon_MO"
deidgroup$trumpvote[219] <- 76.1
deidgroup$county[220] <- "Clinton_PA"
deidgroup$trumpvote[220] <- 65.4
deidgroup$county[221] <- "Waldo_ME"
deidgroup$trumpvote[221] <- 45.9
deidgroup$county[222] <- "Lebanon_PA"
deidgroup$trumpvote[222] <- 65.9
deidgroup$county[223] <- "Hancock_ME"
deidgroup$trumpvote[223] <- 42.8
deidgroup$county[224] <- "Bennington_VT"
deidgroup$trumpvote[224] <- 36.2
deidgroup$county[225] <- "Whitman_WA"
deidgroup$trumpvote[225] <- 45
deidgroup$county[226] <- "Cherokee_OK"
deidgroup$trumpvote[226] <- 60.6
deidgroup$county[227] <- "Warren_IL"
deidgroup$trumpvote[227] <- 55.4
deidgroup$county[228] <- "Merced_CA"
deidgroup$trumpvote[228] <- 43.5
deidgroup$county[229] <- "Johnson_MO"
deidgroup$trumpvote[229] <- 65
deidgroup$county[230] <- "Walla Walla_WA"
deidgroup$trumpvote[230] <- 54.6
deidgroup$county[231] <- "Kittitas_WA"
deidgroup$trumpvote[231] <- 53.7
deidgroup$county[232] <- "Aroostook_ME"
deidgroup$trumpvote[232] <- 55.5
deidgroup$county[233] <- "Gallia_OH"
deidgroup$trumpvote[233] <- 76
deidgroup$county[234] <- "Erath_TX"
deidgroup$trumpvote[234] <- 81.1
deidgroup$county[235] <- "Windham_VT"
deidgroup$trumpvote[235] <- 25.8
deidgroup$county[236] <- "Los Angeles_CA"
deidgroup$trumpvote[236] <- 23.4
deidgroup$county[237] <- "Grand Forks_ND"
deidgroup$trumpvote[237] <- 54.9
deidgroup$county[238] <- "Tolland_CT"
deidgroup$trumpvote[238] <- 44.1
deidgroup$county[239] <- "Morgan_IL"
deidgroup$trumpvote[239] <- 62
deidgroup$county[240] <- "Merrimack_NH"
deidgroup$trumpvote[240] <- 45.9
deidgroup$county[241] <- "Beaverhead_MT"
deidgroup$trumpvote[241] <- 69.1
deidgroup$county[242] <- "Sanpete_UT"
deidgroup$trumpvote[242] <- 65.8
deidgroup$county[243] <- "Bryan_OK"
deidgroup$trumpvote[243] <- 75.9
deidgroup$county[244] <- "Aroostook_ME"
deidgroup$trumpvote[244] <- 55.5
deidgroup$county[245] <- "Callaway_MO"
deidgroup$trumpvote[245] <- 68.2
deidgroup$county[246] <- "Rockbridge_VA"
deidgroup$trumpvote[246] <- 62.4
deidgroup$county[247] <- "Rice_KS"
deidgroup$trumpvote[247] <- 74.3
deidgroup$county[248] <- "Dunn_WI"
deidgroup$trumpvote[248] <- 52.1
deidgroup$county[249] <- "Berks_PA"
deidgroup$trumpvote[249] <- 52.9
deidgroup$county[250] <- "Jackson_IL"
deidgroup$trumpvote[250] <- 44.4
deidgroup$county[251] <- "Otsego_NY"
deidgroup$trumpvote[251] <- 53.4
deidgroup$county[252] <- "Madison_NY"
deidgroup$trumpvote[252] <- 54.4
deidgroup$county[253] <- "Knox_IN"
deidgroup$trumpvote[253] <- 71.5
deidgroup$county[254] <- "Adair_MO"
deidgroup$trumpvote[254] <- 59.4
deidgroup$county[255] <- "Humboldt_CA"
deidgroup$trumpvote[255] <- 32.4
deidgroup$county[256] <- "Union_OR"
deidgroup$trumpvote[256] <- 67.2
deidgroup$county[257] <- "Crawford_KS"
deidgroup$trumpvote[257] <- 58.3
deidgroup$county[258] <- "Pontotoc_OK"
deidgroup$trumpvote[258] <- 70.3
deidgroup$county[259] <- "Franklin_ME"
deidgroup$trumpvote[259] <- 48.2
deidgroup$county[260] <- "St. Lawrence_NY"
deidgroup$trumpvote[260] <- 52.5
deidgroup$county[261] <- "Ulster_NY"
deidgroup$trumpvote[261] <- 51.9
deidgroup$county[262] <- "Nodaway_MO"
deidgroup$trumpvote[262] <- 67.6
deidgroup$county[263] <- "Macoupin_IL"
deidgroup$trumpvote[263] <- 64.9
deidgroup$county[264] <- "Callaway_MO"
deidgroup$trumpvote[264] <- 68.2
deidgroup$county[265] <- "Texas_OK"
deidgroup$trumpvote[265] <- 80
deidgroup$county[266] <- "Washington_ME"
deidgroup$trumpvote[266] <- 54.6
deidgroup$county[267] <- "Allegany_NY"
deidgroup$trumpvote[267] <- 68.4
deidgroup$county[268] <- "Decatur_IA"
deidgroup$trumpvote[268] <- 62
deidgroup$county[269] <- "Butler_OH"
deidgroup$trumpvote[269] <- 62
deidgroup$county[270] <- "Cheshire_NH"
deidgroup$trumpvote[270] <- 41
deidgroup$county[271] <- "Erie_PA"
deidgroup$trumpvote[271] <- 48.8
deidgroup$county[272] <- "McDonough_IL"
deidgroup$trumpvote[272] <- 52.6
deidgroup$county[273] <- "Snyder_PA"
deidgroup$trumpvote[273] <- 71.7
deidgroup$county[274] <- "Portage_OH"
deidgroup$trumpvote[274] <- 52.7
deidgroup$county[275] <- "Oneida_NY"
deidgroup$trumpvote[275] <- 57.8
deidgroup$county[276] <- "Jasper_IN"
deidgroup$trumpvote[276] <- 70.4
deidgroup$county[277] <- "Madison_NY"
deidgroup$trumpvote[277] <- 54.4
deidgroup$county[278] <- "Somerset_MD"
deidgroup$trumpvote[278] <- 57.7
deidgroup$county[279] <- "Phelps_MO"
deidgroup$trumpvote[279] <- 68.6
deidgroup$county[280] <- "Hampshire_MA"
deidgroup$trumpvote[280] <- 26.8
deidgroup$county[281] <- "Latah_ID"
deidgroup$trumpvote[281] <- 40
deidgroup$county[282] <- "Putnam_IN"
deidgroup$trumpvote[282] <- 72.5
deidgroup$county[283] <- "Union_PA"
deidgroup$trumpvote[283] <- 60.9
deidgroup$county[284] <- "Woods_OK"
deidgroup$trumpvote[284] <- 80.4
deidgroup$county[285] <- "Allegany_NY"
deidgroup$trumpvote[285] <- 68.4
deidgroup$county[286] <- "Fayette_IA"
deidgroup$trumpvote[286] <- 57
deidgroup$county[287] <- "Yamhill_OR"
deidgroup$trumpvote[287] <- 50.1
deidgroup$county[288] <- "Cumberland_PA"
deidgroup$trumpvote[288] <- 57.1
deidgroup$county[289] <- "Brewster_TX"
deidgroup$trumpvote[289] <- 49.1
deidgroup$county[290] <- "Mecosta_MI"
deidgroup$trumpvote[290] <- 60.1
deidgroup$county[291] <- "Allegany_MD"
deidgroup$trumpvote[291] <- 72
deidgroup$county[292] <- "Rice_MN"
deidgroup$trumpvote[292] <- 47.9
deidgroup$county[293] <- "Stevens_MN"
deidgroup$trumpvote[293] <- 52.3
deidgroup$county[294] <- "Waller_TX"
deidgroup$trumpvote[294] <- 63
deidgroup$county[295] <- "Iron_UT"
deidgroup$trumpvote[295] <- 65.3
deidgroup$county[296] <- "Sheboygan_WI"
deidgroup$trumpvote[296] <- 55.5
deidgroup$county[297] <- "Yates_NY"
deidgroup$trumpvote[297] <- 57.7
deidgroup$county[298] <- "Bennington_VT"
deidgroup$trumpvote[298] <- 36.2
deidgroup$county[299] <- "Tioga_PA"
deidgroup$trumpvote[299] <- 74.6
deidgroup$county[300] <- "Isabella_MI"
deidgroup$trumpvote[300] <- 48.7
deidgroup$county[301] <- "Monroe_PA"
deidgroup$trumpvote[301] <- 48.1
deidgroup$county[302] <- "Rutland_VT"
deidgroup$trumpvote[302] <- 45.1
deidgroup$county[303] <- "Ashland_OH"
deidgroup$trumpvote[303] <- 71.3
deidgroup$county[304] <- "Mercer_PA"
deidgroup$trumpvote[304] <- 60.6
deidgroup$county[305] <- "Oswego_NY"
deidgroup$trumpvote[305] <- 58.6
deidgroup$county[306] <- "Grady_OK"
deidgroup$trumpvote[306] <- 77.7
deidgroup$county[307] <- "Houghton_MI"
deidgroup$trumpvote[307] <- 54.2
deidgroup$county[308] <- "Saline_NE"
deidgroup$trumpvote[308] <- 59.4
deidgroup$county[309] <- "Walker_TX"
deidgroup$trumpvote[309] <- 65.4
deidgroup$county[310] <- "Lancaster_PA"
deidgroup$trumpvote[310] <- 57.3
deidgroup$county[311] <- "Wood_OH"
deidgroup$trumpvote[311] <- 50.9
deidgroup$county[312] <- "Washington_RI"
deidgroup$trumpvote[312] <- 42.1
deidgroup$county[313] <- "Polk_OR"
deidgroup$trumpvote[313] <- 49.5
deidgroup$county[314] <- "Stutsman_ND"
deidgroup$trumpvote[314] <- 67.5
deidgroup$county[315] <- "Washington_PA"
deidgroup$trumpvote[315] <- 60.8
deidgroup$county[316] <- "Columbia_PA"
deidgroup$trumpvote[316] <- 64.1
deidgroup$county[317] <- "Custer_OK"
deidgroup$trumpvote[317] <- 74.2
deidgroup$county[318] <- "Chautauqua_NY"
deidgroup$trumpvote[318] <- 59.6
deidgroup$county[319] <- "Defiance_OH"
deidgroup$trumpvote[319] <- 64.5
deidgroup$county[320] <- "Hawaii_HI"
deidgroup$trumpvote[320] <- 27.1
deidgroup$county[321] <- "Traill_ND"
deidgroup$trumpvote[321] <- 58.6
deidgroup$county[322] <- "Caledonia_VT"
deidgroup$trumpvote[322] <- 42.7
deidgroup$county[323] <- "Cayuga_NY"
deidgroup$trumpvote[323] <- 53.8
deidgroup$county[324] <- "Guilford_NC"
deidgroup$trumpvote[324] <- 38.7
deidgroup$county[325] <- "St. Lucie_FL"
deidgroup$trumpvote[325] <- 49.9
deidgroup$county[326] <- "DeKalb_GA"
deidgroup$trumpvote[326] <- 16.1
deidgroup$county[327] <- "Volusia_FL"
deidgroup$trumpvote[327] <- 54.8
deidgroup$county[328] <- "Rowan_NC"
deidgroup$trumpvote[328] <- 67.2
deidgroup$county[329] <- "Gwinnett_GA"
deidgroup$trumpvote[329] <- 45.2
deidgroup$county[330] <- "Broward_FL"
deidgroup$trumpvote[330] <- 31.4
deidgroup$county[331] <- "Kenton_KY"
deidgroup$trumpvote[331] <- 59.7
deidgroup$county[332] <- "Monongalia_WV"
deidgroup$trumpvote[332] <- 51.2
deidgroup$county[333] <- "Alamance_NC"
deidgroup$trumpvote[333] <- 55.2
deidgroup$county[334] <- "Cobb_GA"
deidgroup$trumpvote[334] <- 46.7
deidgroup$county[335] <- "Orange_FL"
deidgroup$trumpvote[335] <- 35.7
deidgroup$county[336] <- "Campbell_KY"
deidgroup$trumpvote[336] <- 59
deidgroup$county[337] <- "Faulkner_AR"
deidgroup$trumpvote[337] <- 61.8
deidgroup$county[338] <- "Cherokee_SC"
deidgroup$trumpvote[338] <- 69.7
deidgroup$county[339] <- "Lumpkin_GA"
deidgroup$trumpvote[339] <- 78
deidgroup$county[340] <- "Bibb_GA"
deidgroup$trumpvote[340] <- 38.7
deidgroup$county[341] <- "Faulkner_AR"
deidgroup$trumpvote[341] <- 61.8
deidgroup$county[342] <- "Orange_NC"
deidgroup$trumpvote[342] <- 23
deidgroup$county[343] <- "Dinwiddie_VA"
deidgroup$trumpvote[343] <- 55
deidgroup$county[344] <- "Forsyth_NC"
deidgroup$trumpvote[344] <- 43.4
deidgroup$county[345] <- "Sarasota_FL"
deidgroup$trumpvote[345] <- 54.3
deidgroup$county[346] <- "Lee_FL"
deidgroup$trumpvote[346] <- 58.7
deidgroup$county[347] <- "Roanoke_VA"
deidgroup$trumpvote[347] <- 61.5
deidgroup$county[348] <- "Mecklenburg_NC"
deidgroup$trumpvote[348] <- 33.4
deidgroup$county[349] <- "Pittsylvania_VA"
deidgroup$trumpvote[349] <- 68.6
deidgroup$county[350] <- "Durham_NC"
deidgroup$trumpvote[350] <- 18.5
deidgroup$county[351] <- "Orange_FL"
deidgroup$trumpvote[351] <- 35.7
deidgroup$county[352] <- "Miami-Dade_FL"
deidgroup$trumpvote[352] <- 34.1
deidgroup$county[353] <- "Tuscaloosa_AL"
deidgroup$trumpvote[353] <- 58.4
deidgroup$county[354] <- "Alachua_FL"
deidgroup$trumpvote[354] <- 36.4
deidgroup$county[355] <- "Fairfax_VA"
deidgroup$trumpvote[355] <- 29.1
deidgroup$county[356] <- "Newport News_VA"
deidgroup$trumpvote[356] <- 34.6
deidgroup$county[357] <- "Forrest_MS"
deidgroup$trumpvote[357] <- 55.5
deidgroup$county[358] <- "Escambia_FL"
deidgroup$trumpvote[358] <- 58.3
deidgroup$county[359] <- "Brevard_FL"
deidgroup$trumpvote[359] <- 57.8
deidgroup$county[360] <- "Lee_FL"
deidgroup$trumpvote[360] <- 58.7
deidgroup$county[361] <- "Aiken_SC"
deidgroup$trumpvote[361] <- 61.5
deidgroup$county[362] <- "Lynchburg_VA"
deidgroup$trumpvote[362] <- 50.9
deidgroup$county[363] <- "Mobile_AL"
deidgroup$trumpvote[363] <- 55.7
deidgroup$county[364] <- "Mobile_AL"
deidgroup$trumpvote[364] <- 55.7
deidgroup$county[365] <- "Albemarle_VA"
deidgroup$trumpvote[365] <- 34.3
deidgroup$county[366] <- "Scott_VA"
deidgroup$trumpvote[366] <- 62.3
deidgroup$county[367] <- "Collier_FL"
deidgroup$trumpvote[367] <- 61.8
deidgroup$county[368] <- "Lake_FL"
deidgroup$trumpvote[368] <- 60
deidgroup$county[369] <- "St. Johns_FL"
deidgroup$trumpvote[369] <- 65
deidgroup$county[370] <- "Amherst_VA"
deidgroup$trumpvote[370] <- 63.6
deidgroup$county[371] <- "Lee_AL"
deidgroup$trumpvote[371] <- 59.5
deidgroup$county[372] <- "Horry_SC"
deidgroup$trumpvote[372] <- 67.3
deidgroup$county[373] <- "Clayton_GA"
deidgroup$trumpvote[373] <- 13.2
deidgroup$county[374] <- "Pickens_SC"
deidgroup$trumpvote[374] <- 73.9
deidgroup$county[375] <- "Buncombe_NC"
deidgroup$trumpvote[375] <- 41.1
deidgroup$county[376] <- "Duval_FL"
deidgroup$trumpvote[376] <- 49
deidgroup$county[377] <- "Richmond City_VA"
deidgroup$trumpvote[377] <- 15
deidgroup$county[378] <- "Spotsylvania_VA"
deidgroup$trumpvote[378] <- 55.8
deidgroup$county[379] <- "Sebastian_AR"
deidgroup$trumpvote[379] <- 65.2
deidgroup$county[380] <- "Union_NC"
deidgroup$trumpvote[380] <- 64
deidgroup$county[381] <- "Wilson_TN"
deidgroup$trumpvote[381] <- 69.8
deidgroup$county[382] <- "Williamsburg City_VA"
deidgroup$trumpvote[382] <- 25.5
deidgroup$county[383] <- "Bay_FL"
deidgroup$trumpvote[383] <- 71.2
deidgroup$county[384] <- "Greenville_SC"
deidgroup$trumpvote[384] <- 59.4
deidgroup$county[385] <- "Kanawha_WV"
deidgroup$trumpvote[385] <- 58
deidgroup$county[386] <- "Seminole_FL"
deidgroup$trumpvote[386] <- 48.7
deidgroup$county[387] <- "Salem City_VA"
deidgroup$trumpvote[387] <- 59.6
deidgroup$county[388] <- "Beaufort_SC"
deidgroup$trumpvote[388] <- 54.9
deidgroup$county[389] <- "Mecklenburg_NC"
deidgroup$trumpvote[389] <- 33.4
deidgroup$county[390] <- "Palm Beach_FL"
deidgroup$trumpvote[390] <- 41.2
deidgroup$county[391] <- "Orangeburg_SC"
deidgroup$trumpvote[391] <- 30.7
deidgroup$county[392] <- "Hinds_MS"
deidgroup$trumpvote[392] <- 27.2
deidgroup$county[393] <- "Essex_NJ"
deidgroup$trumpvote[393] <- 20.7
deidgroup$county[394] <- "Ingham_MI"
deidgroup$trumpvote[394] <- 33.2
deidgroup$county[395] <- "Dutchess_NY"
deidgroup$trumpvote[395] <- 48.4
deidgroup$county[396] <- "Merrimack_NH"
deidgroup$trumpvote[396] <- 45.9
deidgroup$county[397] <- "Chester_PA"
deidgroup$trumpvote[397] <- 43.3
deidgroup$county[398] <- "Kent_DE"
deidgroup$trumpvote[398] <- 49.8
deidgroup$county[399] <- "Mercer_NJ"
deidgroup$trumpvote[399] <- 30.1
deidgroup$county[400] <- "Monroe_NY"
deidgroup$trumpvote[400] <- 40.3
deidgroup$county[401] <- "Hampshire_MA"
deidgroup$trumpvote[401] <- 26.8
deidgroup$county[402] <- "Cumberland_PA"
deidgroup$trumpvote[402] <- 57.1
deidgroup$county[403] <- "Jefferson_CO"
deidgroup$trumpvote[403] <- 42.1
deidgroup$county[404] <- "Warren_IA"
deidgroup$trumpvote[404] <- 54.9
deidgroup$county[405] <- "Dutchess_NY"
deidgroup$trumpvote[405] <- 48.4
deidgroup$county[406] <- "Dallas_TX"
deidgroup$trumpvote[406] <- 34.9
deidgroup$county[407] <- "Williamson_TX"
deidgroup$trumpvote[407] <- 51.9
deidgroup$county[408] <- "Yellowstone_MT"
deidgroup$trumpvote[408] <- 59.6
deidgroup$county[409] <- "Oklahoma_OK"
deidgroup$trumpvote[409] <- 51.7
deidgroup$county[410] <- "San_Diego_CA"
deidgroup$trumpvote[410] <- 38.2
deidgroup$county[411] <- "Montgomery_PA"
deidgroup$trumpvote[411] <- 37.6
deidgroup$county[412] <- "Rogers_OK"
deidgroup$trumpvote[412] <- 75.7
deidgroup$county[413] <- "New Haven_CT"
deidgroup$trumpvote[413] <- 42.1
deidgroup$county[414] <- "Will_IL"
deidgroup$trumpvote[414] <- 44.6
deidgroup$county[415] <- "Allegheny_PA"
deidgroup$trumpvote[415] <- 40
deidgroup$county[416] <- "Nassau_NY"
deidgroup$trumpvote[416] <- 45.9
deidgroup$county[417] <- "Marion_IN"
deidgroup$trumpvote[417] <- 36.1
deidgroup$county[418] <- "Delaware_PA"
deidgroup$trumpvote[418] <- 37.4
deidgroup$county[419] <- "Essex_NJ"
deidgroup$trumpvote[419] <- 20.7
deidgroup$county[420] <- "Oakland_MI"
deidgroup$trumpvote[420] <- 43.6
deidgroup$county[421] <- "New Haven_CT"
deidgroup$trumpvote[421] <- 42.1
deidgroup$county[422] <- "Gloucester_NJ"
deidgroup$trumpvote[422] <- 48.4
deidgroup$county[423] <- "Monterey_CA"
deidgroup$trumpvote[423] <- 27.3
deidgroup$county[424] <- "Johnson_IN"
deidgroup$trumpvote[424] <- 68.6
deidgroup$county[425] <- "Stanislaus_CA"
deidgroup$trumpvote[425] <- 46.7
deidgroup$county[426] <- "Madison_IL"
deidgroup$trumpvote[426] <- 55
deidgroup$county[427] <- "Monroe_NY"
deidgroup$trumpvote[427] <- 40.3
deidgroup$county[428] <- "Cumberland_ME"
deidgroup$trumpvote[428] <- 33.7
deidgroup$county[429] <- "Montgomery_PA"
deidgroup$trumpvote[429] <- 37.6
deidgroup$county[430] <- "Whatcom_WA"
deidgroup$trumpvote[430] <- 37.2
deidgroup$county[431] <- "Sarasota_FL"
deidgroup$trumpvote[431] <- 62.2
deidgroup$county[432] <- "Jasper_MO"
deidgroup$trumpvote[432] <- 72.8
deidgroup$county[433] <- "Bexar_TX"
deidgroup$trumpvote[433] <- 41
deidgroup$county[434] <- "San Bernardino_CA"
deidgroup$trumpvote[434] <- 42.4
deidgroup$county[435] <- "Prince George's_MD"
deidgroup$trumpvote[435] <- 8.3
deidgroup$county[436] <- "Randall_TX"
deidgroup$trumpvote[436] <- 80.6
deidgroup$county[437] <- "Windham_CT"
deidgroup$trumpvote[437] <- 50.8
deidgroup$county[438] <- "Nassau_NY"
deidgroup$trumpvote[438] <- 45.9
deidgroup$county[439] <- "Kenosha_WI"
deidgroup$trumpvote[439] <- 47.5
deidgroup$county[440] <- "Delaware_OH"
deidgroup$trumpvote[440] <- 55.6
deidgroup$county[441] <- "New Haven_CT"
deidgroup$trumpvote[441] <- 42.1
deidgroup$county[442] <- "BaltimoreCounty_MD"
deidgroup$trumpvote[442] <- 39.1
deidgroup$county[443] <- "BaltimoreCounty_MD"
deidgroup$trumpvote[443] <- 39.1
deidgroup$county[444] <- "Franklin_OH"
deidgroup$trumpvote[444] <- 34.7
deidgroup$county[445] <- "Santa Barbara_CA"
deidgroup$trumpvote[445] <- 32.7
deidgroup$county[446] <- "Monroe_NY"
deidgroup$trumpvote[446] <- 40.3
deidgroup$county[447] <- "Los Angeles_CA"
deidgroup$trumpvote[447] <- 23.4
deidgroup$county[448] <- "Santa Barbara_CA"
deidgroup$trumpvote[448] <- 32.7
deidgroup$county[449] <- "Albany_WY"
deidgroup$trumpvote[449] <- 46.3
deidgroup$county[450] <- "Los Angeles_CA"
deidgroup$trumpvote[450] <- 23.4
deidgroup$county[451] <- "Bucks_PA"
deidgroup$trumpvote[451] <- 47.8
deidgroup$county[452] <- "Baltimore_MD"
deidgroup$trumpvote[452] <- 39.1
deidgroup$county[453] <- "Hartford_CT"
deidgroup$trumpvote[453] <- 37.1
deidgroup$county[454] <- "Los Angeles_CA"
deidgroup$trumpvote[454] <- 23.4
deidgroup$county[455] <- "Los Angeles_CA"
deidgroup$trumpvote[455] <- 23.4
deidgroup$county[456] <- "Washington_OH"
deidgroup$trumpvote[456] <- 68.6
deidgroup$county[457] <- "Erie_NY"
deidgroup$trumpvote[457] <- 45.4
deidgroup$county[458] <- "DeKalb_IL"
deidgroup$trumpvote[458] <- 44.7
deidgroup$county[459] <- "Hampden_MA"
deidgroup$trumpvote[459] <- 39.1
deidgroup$county[460] <- "York_ME"
deidgroup$trumpvote[460] <- 44.2
deidgroup$county[461] <- "Cumberland_PA"
deidgroup$trumpvote[461] <- 57.1
deidgroup$county[462] <- "Montgomery_PA"
deidgroup$trumpvote[462] <- 37.6
deidgroup$county[463] <- "Norfolk_MA"
deidgroup$trumpvote[463] <- 33.3
deidgroup$county[464] <- "Cape Girardeau_MO"
deidgroup$trumpvote[464] <- 73.1
deidgroup$county[465] <- "St. Louis_MO"
deidgroup$trumpvote[465] <- 39.5
deidgroup$county[466] <- "Carroll_MD"
deidgroup$trumpvote[466] <- 65.5
deidgroup$county[467] <- "Hampden_MA"
deidgroup$trumpvote[467] <- 39.1
deidgroup$county[468] <- "Kent_RI"
deidgroup$trumpvote[468] <- 47.8
deidgroup$county[469] <- "Montgomery_PA"
deidgroup$trumpvote[469] <- 37.6
deidgroup$county[470] <- "Nassau_NY"
deidgroup$trumpvote[470] <- 45.9
deidgroup$county[471] <- "Saratoga_NY"
deidgroup$trumpvote[471] <- 49.1
deidgroup$county[472] <- "Vanderburgh_IN"
deidgroup$trumpvote[472] <- 56.2
deidgroup$county[473] <- "Bergen_NJ"
deidgroup$trumpvote[473] <- 42.5
deidgroup$county[474] <- "Solano_CA"
deidgroup$trumpvote[474] <- 31.8
deidgroup$county[475] <- "Hartford_CT"
deidgroup$trumpvote[475] <- 37.1
deidgroup$county[476] <- "Lake_IL"
deidgroup$trumpvote[476] <- 37
deidgroup$county[477] <- "Adams_PA"
deidgroup$trumpvote[477] <- 66.3
deidgroup$county[478] <- "McLean_IL"
deidgroup$trumpvote[478] <- 46.9
deidgroup$county[479] <- "Hartford_CT"
deidgroup$trumpvote[479] <- 37.1
deidgroup$county[480] <- "DuPage_IL"
deidgroup$trumpvote[480] <- 39.8
deidgroup$county[481] <- "Norfolk_MA"
deidgroup$trumpvote[481] <- 33.3
deidgroup$county[482] <- "Westmoreland_PA"
deidgroup$trumpvote[482] <- 64.1
deidgroup$county[483] <- "Wayne_IN"
deidgroup$trumpvote[483] <- 62.7
deidgroup$county[484] <- "Kent_MI"
deidgroup$trumpvote[484] <- 48.3
deidgroup$county[485] <- "St_Louis_MO"
deidgroup$trumpvote[485] <- 39.5
deidgroup$county[486] <- "Nassau_NY"
deidgroup$trumpvote[486] <- 45.9
deidgroup$county[487] <- "Chester_PA"
deidgroup$trumpvote[487] <- 43.3
deidgroup$county[488] <- "Licking_OH"
deidgroup$trumpvote[488] <- 62.1
deidgroup$county[489] <- "New Haven_CT"
deidgroup$trumpvote[489] <- 42.1
deidgroup$county[490] <- "Hampshire_MA"
deidgroup$trumpvote[490] <- 26.8
deidgroup$county[491] <- "Union_NJ"
deidgroup$trumpvote[491] <- 30.8
deidgroup$county[492] <- "Weld_CO"
deidgroup$trumpvote[492] <- 56.7
deidgroup$county[493] <- "Westchester_NY"
deidgroup$trumpvote[493] <- 32.1
deidgroup$county[494] <- "Lake_OH"
deidgroup$trumpvote[494] <- 55.5
deidgroup$county[495] <- "Orange_CA"
deidgroup$trumpvote[495] <- 43.3
deidgroup$county[496] <- "Lehigh_PA"
deidgroup$trumpvote[496] <- 45.9
deidgroup$county[497] <- "Orange_NY"
deidgroup$trumpvote[497] <- 51.2
deidgroup$county[498] <- "Middlesex_MA"
deidgroup$trumpvote[498] <- 28.2
deidgroup$county[499] <- "Santa Cruz_CA"
deidgroup$trumpvote[499] <- 17.8
deidgroup$county[500] <- "Middlesex_MA"
deidgroup$trumpvote[500] <- 28.2
deidgroup$county[501] <- "York_PA"
  deidgroup$trumpvote[501] <- 62.5
  deidgroup$county[502] <- "Baltimore_MD"
  deidgroup$trumpvote[502] <- 39.1
  deidgroup$county[503] <- "Warren_NJ"
  deidgroup$trumpvote[503] <- 60.7
  deidgroup$county[504] <- "Honolulu_HI"
  deidgroup$trumpvote[504] <- 31.7
  deidgroup$county[505] <- "San Bernardino_CA"
  deidgroup$trumpvote[505] <- 42.4
  deidgroup$county[506] <- "Tompkins_NY"
  deidgroup$trumpvote[506] <- 25.6
  deidgroup$county[507] <- "Middlesex_MA"
  deidgroup$trumpvote[507] <- 28.2
  deidgroup$county[508] <- "Black Hawk_IA"
  deidgroup$trumpvote[508] <- 43.3
  deidgroup$county[509] <- "Providence_RI"
  deidgroup$trumpvote[509] <- 37.3
  deidgroup$county[510] <- "San Luis Obispo_CA"
  deidgroup$trumpvote[510] <- 42.3
  deidgroup$county[511] <- "Atlantic_NJ"
  deidgroup$trumpvote[511] <- 45.3
  deidgroup$county[512] <- "Hillsborough_NH"
  deidgroup$trumpvote[512] <- 47.4
  deidgroup$county[513] <- "Brown_WI"
  deidgroup$trumpvote[513] <- 52.7
  deidgroup$county[514] <- "Penobscot_ME"
  deidgroup$trumpvote[514] <- 51.9
  deidgroup$county[515] <- "Middlesex_MA"
  deidgroup$trumpvote[515] <- 28.2
  deidgroup$county[516] <- "Midland_TX"
  deidgroup$trumpvote[516] <- 75.7
  deidgroup$county[517] <- "Montgomery_OH"
  deidgroup$trumpvote[517] <- 48.4
  deidgroup$county[518] <- "Los Angeles_CA"
  deidgroup$trumpvote[518] <- 23.4
  deidgroup$county[519] <- "Bergen_NJ"
  deidgroup$trumpvote[519] <- 42.5
  deidgroup$county[520] <- "Nassau_NY"
  deidgroup$trumpvote[520] <- 45.9
  deidgroup$county[521] <- "Hampden_MA"
  deidgroup$trumpvote[521] <- 39.1
  deidgroup$county[522] <- "Clinton_NY"
  deidgroup$trumpvote[522] <- 46.4
  deidgroup$county[523] <- "Los Angeles_CA"
  deidgroup$trumpvote[523] <- 23.4
  deidgroup$county[524] <- "St. Charles_MO"
  deidgroup$trumpvote[524] <- 60.6
  deidgroup$county[525] <- "Rensselaer_NY"
  deidgroup$trumpvote[525] <- 48.4
  deidgroup$county[526] <- "Morris_NJ"
  deidgroup$trumpvote[526] <- 50.4
  deidgroup$county[527] <- "Dallas_TX"
  deidgroup$trumpvote[527] <- 34.9
  deidgroup$county[528] <- "Wayne_MI"
  deidgroup$trumpvote[528] <- 29.5
  deidgroup$county[529] <- "Delaware_PA"
  deidgroup$trumpvote[529] <- 37.4
  deidgroup$county[530] <-"St_Louis_MO"
  deidgroup$trumpvote[530] <- 39.5
  deidgroup$county[531] <- "Floyd_IN"
  deidgroup$trumpvote[531] <- 57.6
  deidgroup$county[532] <- "Washington_PA"
  deidgroup$trumpvote[532] <- 60.8
  deidgroup$county[533] <- "Westchester_NY"
  deidgroup$trumpvote[533] <- 32.1
  deidgroup$county[534] <- "Clay_MO"
  deidgroup$trumpvote[534] <- 52.5
  deidgroup$county[535] <- "Bay_MI"
  deidgroup$trumpvote[535] <- 53.5
  deidgroup$county[536] <- "Norfolk_MA"
  deidgroup$trumpvote[536] <- 33.3
  deidgroup$county[537] <- "Suffolk_NY"
  deidgroup$trumpvote[537] <- 52.5
  deidgroup$county[538] <- "Prince George's_MD"
  deidgroup$trumpvote[538] <- 8.3
  deidgroup$county[539] <- "Chittenden_VT"
  deidgroup$trumpvote[539] <- 23.7
  deidgroup$county[550] <- "Benton_OR"
  deidgroup$trumpvote[540] <- 28.6
  deidgroup$county[541] <- "Bristol_MA"
  deidgroup$trumpvote[541] <- 42.6
  deidgroup$county[542] <- "Albany_NY"
  deidgroup$trumpvote[542] <- 35.2
  deidgroup$county[543] <- "Nassau_NY"
  deidgroup$trumpvote[543] <- 45.9
  deidgroup$county[544] <- "Canyon_ID"
  deidgroup$trumpvote[544] <- 64.9
  deidgroup$county[545] <- "Nassau_NY"
  deidgroup$trumpvote[545] <- 45.9
  deidgroup$county[546] <- "Orange_CA"
  deidgroup$trumpvote[546] <- 43.3
  deidgroup$county[547] <- "Nassau_NY"
  deidgroup$trumpvote[547] <- 45.9
  deidgroup$county[548] <- "Cole_MO"
  deidgroup$trumpvote[548] <- 66
  deidgroup$county[549] <- "Sonoma_CA"
  deidgroup$trumpvote[549] <- 22.8
  deidgroup$county[550] <- "Westchester_NY"
  deidgroup$trumpvote[550] <- 32.1
  deidgroup$county[551] <- "New Haven_CT"
  deidgroup$trumpvote[551] <- 42.1
  deidgroup$county[552] <- "Washington_DC"
  deidgroup$trumpvote[552] <- 4.1
  deidgroup$county[553] <- "Berks_PA"
  deidgroup$trumpvote[553] <- 52.9
  deidgroup$county[554] <- "King_WA"
  deidgroup$trumpvote[554] <- 21.7
  deidgroup$county[555] <- "Broome_NY"
  deidgroup$trumpvote[555] <- 49
  deidgroup$county[556] <- "Oakland_MI"
  deidgroup$trumpvote[556] <- 43.6
  deidgroup$county[557] <- "Washington_OR"
  deidgroup$trumpvote[557] <- 32.7
  deidgroup$county[558] <- "Bristol_RI"
  deidgroup$trumpvote[558] <- 36
  deidgroup$county[559] <- "New Castle_RI"
  deidgroup$trumpvote[559] <- 32.7
  deidgroup$county[560] <- "Harris_TX"
  deidgroup$trumpvote[560] <- 41.8
  deidgroup$county[561] <- "Platte_MO"
  deidgroup$trumpvote[561] <- 53.5
  deidgroup$county[562] <- "Pierce_WI"
  deidgroup$trumpvote[562] <- 53.4
  deidgroup$county[563] <- "Frederick_MD"
  deidgroup$trumpvote[563] <- 49.1
  deidgroup$county[564] <- "Newport_RI"
  deidgroup$trumpvote[564] <- 37.6
  deidgroup$county[565] <- "Lorain_OH"
  deidgroup$trumpvote[565] <- 47.8
  deidgroup$county[566] <- "Mercer_NJ"
  deidgroup$trumpvote[566] <- 30.1
  deidgroup$county[567] <- "Hampshire_MA"
  deidgroup$trumpvote[567] <- 26.8
  deidgroup$county[568] <- "Hays_TX"
  deidgroup$trumpvote[568] <- 47.2
  deidgroup$county[569] <- "Boone_MO"
  deidgroup$trumpvote[569] <- 43.4
  deidgroup$county[570] <- "Delaware_IN"
  deidgroup$trumpvote[570] <- 54.2
  deidgroup$county[571] <- "Crawford_PA"
  deidgroup$trumpvote[571] <- 67.2
  deidgroup$county[572] <- "Prince George's_MD"
  deidgroup$trumpvote[572] <- 8.3
  deidgroup$county[573] <- "Cortland_NY"
  deidgroup$trumpvote[573] <- 50
  deidgroup$county[574] <- "Los Angeles_CA"
  deidgroup$trumpvote[574] <- 23.4
  deidgroup$county[575] <- "Santa Clara_CA"
  deidgroup$trumpvote[575] <- 20.9
  deidgroup$county[576] <- "Bristol_MA"
  deidgroup$trumpvote[576] <- 42.6
  deidgroup$county[577] <- "Woodbury_IA"
  deidgroup$trumpvote[577] <- 57.4
  deidgroup$county[578] <- "Los Angeles_CA"
  deidgroup$trumpvote[578] <- 23.4
  deidgroup$county[579] <- "Los Angeles_CA"
  deidgroup$trumpvote[579] <- 23.4
  deidgroup$county[580] <- "Baltimore_MD"
  deidgroup$trumpvote[580] <- 39.1
  deidgroup$county[581] <- "Lancaster_PA"
  deidgroup$trumpvote[581] <- 57.3
  deidgroup$county[582] <- "Strafford_NH"
  deidgroup$trumpvote[582] <- 42.8
  deidgroup$county[583] <- "Oneida_NY"
  deidgroup$trumpvote[583] <- 57.8
  deidgroup$county[584] <- "Norfolk_MA"
  deidgroup$trumpvote[584] <- 33.3
  deidgroup$county[585] <- "Weber_UT"
  deidgroup$trumpvote[585] <- 47.2
  deidgroup$county[586] <- "Calhoun_MI"
  deidgroup$trumpvote[586] <- 53.6
  deidgroup$county[587] <- "Plymouth_MA"
  deidgroup$trumpvote[587] <- 43.4
  deidgroup$county[588] <- "Westchester_NY"
  deidgroup$trumpvote[588] <- 32.1
  deidgroup$county[589] <- "Montgomery_PA"
  deidgroup$trumpvote[589] <- 37.6
  deidgroup$county[590] <- "ErieCounty_NY"
  deidgroup$trumpvote[590] <- 45.4
  deidgroup$county[591] <- "Northampton_PA"
  deidgroup$trumpvote[591] <- 50
  deidgroup$county[592] <- "Walworth_WI"
  deidgroup$trumpvote[592] <- 57
  deidgroup$county[593] <- "Providence_RI"
  deidgroup$trumpvote[593] <- 37.3
  deidgroup$county[594] <- "St. Clair_IL"
  deidgroup$trumpvote[594] <- 44.9
  deidgroup$county[595] <- "Los Angeles_CA"
  deidgroup$trumpvote[595] <- 23.4
  deidgroup$county[596] <- "Fairfield_CT"
  deidgroup$trumpvote[596] <- 37.9
  deidgroup$county[597] <- "Passaic_NJ"
  deidgroup$trumpvote[597] <- 37.8
  deidgroup$county[598] <- "Mercer_NJ"
  deidgroup$trumpvote[598] <- 30.1
  deidgroup$county[599] <- "CookCounty_IL"
  deidgroup$trumpvote[599] <- 21.4
  deidgroup$county[600] <- "Essex_MA"
  deidgroup$trumpvote[600] <-  36
  deidgroup$county[601] <- "Kenosha_WI"
  deidgroup$trumpvote[601] <- 47.5
  deidgroup$county[602] <- "Monmouth_NJ"
  deidgroup$trumpvote[602] <- 53.1
  deidgroup$county[603] <- "MonroeCounty_NY"
  deidgroup$trumpvote[603] <- 40.3
  deidgroup$county[604] <- "Portage_OH"
  deidgroup$trumpvote[604] <- 52.7
  deidgroup$county[605] <- "New Castle_DE"
  deidgroup$trumpvote[605] <- 32.7
  deidgroup$county[606] <- "WestchesterCounty_NY"
  deidgroup$trumpvote[606] <- 32.1
  deidgroup$county[607] <- "Lehigh_PA"
  deidgroup$trumpvote[607] <- 45.9
  deidgroup$county[608] <- "Santa Clara_CA"
  deidgroup$trumpvote[608] <- 20.9
  deidgroup$county[609] <- "Lowndes_GA"
  deidgroup$trumpvote[609] <- 57.9
  deidgroup$county[610] <- "Tuscaloosa_AL"
  deidgroup$trumpvote[610] <- 58.4
  deidgroup$county[611] <- "Dougherty_GA"
  deidgroup$trumpvote[611] <- 30.1
  deidgroup$county[612] <- "Forsyth_NC"
  deidgroup$trumpvote[612] <- 43.4
  deidgroup$county[613] <- "Franklin_KY"
  deidgroup$trumpvote[613] <- 49.5
  deidgroup$county[614] <- "Escambia_FL"
  deidgroup$trumpvote[614] <- 58.3
  deidgroup$county[615] <- "Rockingham_VA"
  deidgroup$trumpvote[615] <- 69.2
  deidgroup$county[616] <- "Fayette_KY"
  deidgroup$trumpvote[616] <- 41.8
  deidgroup$county[617] <- "Wake_NC"
  deidgroup$trumpvote[617] <- 37.9
  deidgroup$county[618] <- "Muscogee_GA"
  deidgroup$trumpvote[618] <- 39.4
  deidgroup$county[619] <- "Jefferson_AR"
  deidgroup$trumpvote[619] <- 35.7
  deidgroup$county[620] <- "Blount_TN"
  deidgroup$trumpvote[620] <- 72.1
  deidgroup$county[621] <- "Rutherford_TN"
  deidgroup$trumpvote[621] <- 60.5
  deidgroup$county[622] <- "Boyle_KY"
  deidgroup$trumpvote[622] <- 62.1
  deidgroup$county[623] <- "Palm Beach_FL"
  deidgroup$trumpvote[623] <- 41.2
  deidgroup$county[624] <- "Miami-Dade_FL"
  deidgroup$trumpvote[624] <- 34.1
  deidgroup$county[625] <- "Winchester City_VA"
  deidgroup$trumpvote[625] <- 45.3
  deidgroup$county[626] <- "Pitt_NC"
  deidgroup$trumpvote[626] <- 45
  deidgroup$county[627] <- "Washington_TN"
  deidgroup$trumpvote[627] <- 69.2
  deidgroup$county[628] <- "Spartanburg_SC"
  deidgroup$trumpvote[628] <- 63
  deidgroup$county[629] <- "Lafayette_LA"
  deidgroup$trumpvote[629] <- 64.6
  deidgroup$county[630] <- "Kanawha_WV"
  deidgroup$trumpvote[630] <- 58
  deidgroup$county[631] <- "Calcasieu_LA"
  deidgroup$trumpvote[631] <- 64.7
  deidgroup$county[632] <- "Caddo_LA"
  deidgroup$trumpvote[632] <- 46.3
  deidgroup$county[633] <- "Radford_VA"
  deidgroup$trumpvote[633] <- 43.7
  deidgroup$county[634] <- "Warren_KY"
  deidgroup$trumpvote[634] <- 59.2
  deidgroup$county[635] <- "Wilson_NC"
  deidgroup$trumpvote[635] <- 46.3
  deidgroup$county[636] <- "Craighead_AR"
  deidgroup$trumpvote[636] <- 64.4
  deidgroup$county[637] <- "Ouachita_LA"
  deidgroup$trumpvote[637] <- 61.4
  deidgroup$county[638] <- "Hall_GA"
  deidgroup$trumpvote[638] <- 73.7
  deidgroup$county[639] <- "Glynn_GA"
  deidgroup$trumpvote[639] <- 63.1
  deidgroup$county[640] <- "Cabell_WV"
  deidgroup$trumpvote[640] <- 60.1
  deidgroup$county[641] <- "Greenwood_SC"
  deidgroup$trumpvote[641] <- 59
  deidgroup$county[642] <- "Lexington City_VA"
  deidgroup$trumpvote[642] <- 31.3
  deidgroup$county[643] <- "Buncombe_NC"
  deidgroup$trumpvote[643] <- 41.1
  deidgroup$county[644] <- "Leon_FL"
  deidgroup$trumpvote[644] <- 35.4
  deidgroup$county[645] <- "Chatham_GA"
  deidgroup$trumpvote[645] <- 41.2
  deidgroup$county[646] <- "Leon_FL"
  deidgroup$trumpvote[646] <- 35.4
  deidgroup$county[647] <- "Okaloosa_FL"
  deidgroup$trumpvote[647] <- 71.3
  deidgroup$county[648] <- "Lynchburg City_VA"
  deidgroup$trumpvote[648] <- 50.9
  deidgroup$county[649] <- "Palm Beach_FL"
  deidgroup$trumpvote[649] <- 41.2
  deidgroup$county[650] <- "DeKalb_GA"
  deidgroup$trumpvote[650] <- 16.1
  deidgroup$county[651] <- "Lauderdale_FL"
  deidgroup$trumpvote[651] <- 71.5
  deidgroup$county[652] <- "Baldwin_GA"
  deidgroup$trumpvote[652] <- 47.8
  deidgroup$county[653] <- "York_SC"
  deidgroup$trumpvote[653] <- 58.4
  deidgroup$county[654] <- "Madison_AL"
  deidgroup$trumpvote[654] <- 55.9
  deidgroup$county[655] <- "Washington_AR"
  deidgroup$trumpvote[655] <- 50.8
  deidgroup$county[656] <- "Hinds_MS"
  deidgroup$trumpvote[656] <- 26.9
  deidgroup$county[657] <- "Richland_SC"
  deidgroup$trumpvote[657] <- 31.1
  deidgroup$county[658] <- "Hamilton_TN"
  deidgroup$trumpvote[658] <- 55.8
  deidgroup$county[659] <- "Clarke_GA"
  deidgroup$trumpvote[659] <- 28.3
  deidgroup$county[660] <- "Brevard_FL"
  deidgroup$trumpvote[660] <- 57.8
  deidgroup$county[661] <- "Marion_WV"
  deidgroup$trumpvote[661] <- 63.7
  deidgroup$county[662] <- "Staunton City_VA"
  deidgroup$trumpvote[662] <- 46
  deidgroup$county[663] <- "Independence_AR"
  deidgroup$trumpvote[663] <- 73
  deidgroup$county[664] <- "Yavapai_AZ"
  deidgroup$trumpvote[664] <- 63.5
  deidgroup$county[665] <- "Hancock_OH"
  deidgroup$trumpvote[665] <- 67.5
  deidgroup$county[666] <- "Marion_OR"
  deidgroup$trumpvote[666] <- 49
  deidgroup$county[667] <- "New York_NY"
  deidgroup$trumpvote[667] <- 10
  deidgroup$county[668] <- "Polk_IA"
  deidgroup$trumpvote[668] <- 40.9
  deidgroup$county[669] <- "Johnson_IA"
  deidgroup$trumpvote[669] <- 27.8
  deidgroup$county[670] <- "Los Angeles_CA" 
  deidgroup$trumpvote[670] <- 23.4
  deidgroup$county[671] <- "Pueblo_CO"
  deidgroup$trumpvote[671] <- 46.2
  deidgroup$county[672] <- "Wayne_OH"
  deidgroup$trumpvote[672] <- 65.1
  deidgroup$county[673] <- "Albany_NY"
  deidgroup$trumpvote[673] <- 35.2
  deidgroup$county[674] <- "Burleigh_ND"
  deidgroup$trumpvote[674] <- 69.3
  deidgroup$county[675] <- "Oneida_NY"
  deidgroup$trumpvote[675] <- 57.8
  deidgroup$county[676] <- "Onondaga_NY"
  deidgroup$trumpvote[676] <- 40.8
  deidgroup$county[677] <- "Essex_MA"
  deidgroup$trumpvote[677] <- 36
  deidgroup$county[678] <- "St. Louis_MN"
  deidgroup$trumpvote[678] <- 40.1
  deidgroup$county[679] <- "Middlesex_CT"
  deidgroup$trumpvote[679] <- 43.9
  deidgroup$county[680] <- "Champaign_IL"
  deidgroup$trumpvote[680] <- 37.3
  deidgroup$county[681] <- "Nueces_TX"
  deidgroup$trumpvote[681] <- 48.8
  deidgroup$county[682] <- "Ontario_NY"
  deidgroup$trumpvote[682] <- 51.1
  deidgroup$county[683] <- "Boone_MO"
  deidgroup$trumpvote[683] <- 43.4
  deidgroup$county[684] <- "Centre_PA"
  deidgroup$trumpvote[684] <- 46.6
  deidgroup$county[685] <- "Alameda_CA"
  deidgroup$trumpvote[685] <- 14.9
  deidgroup$county[686] <- "Worcester_MA"
  deidgroup$trumpvote[686] <- 41.2
  deidgroup$county[687] <- "Riley_KS"
  deidgroup$trumpvote[687] <- 47.9
  deidgroup$county[688] <- "Fond du Lac_WI"
  deidgroup$trumpvote[688] <- 60.8
  deidgroup$county[689] <- "New Haven_CT"
  deidgroup$trumpvote[689] <- 42.1
  deidgroup$county[690] <- "Denton_TX"
  deidgroup$trumpvote[690] <- 57.7
  deidgroup$county[691] <- "Middlesex_MA"
  deidgroup$trumpvote[691] <- 28.2
  deidgroup$county[692] <- "Thurston_WA"
  deidgroup$trumpvote[692] <- 37.8
  deidgroup$county[693] <- "Scioto_OH"
  deidgroup$trumpvote[693] <- 66.7
  deidgroup$county[694] <- "Rock_WI"
  deidgroup$trumpvote[694] <- 42
  deidgroup$county[695] <- "Worcester_MA"
  deidgroup$trumpvote[695] <- 41.2
  deidgroup$county[696] <- "San Joaquin_CA"
  deidgroup$trumpvote[696] <- 41
  deidgroup$county[697] <- "Chittenden_VT"
  deidgroup$trumpvote[697] <- 23.7
  deidgroup$county[698] <- "Tom Green_TX"
  deidgroup$trumpvote[698] <- 71.8
  deidgroup$county[699] <- "Knox_IL"
  deidgroup$trumpvote[699] <- 48.5
  
    deidgroup$county[700] <- "Middlesex_NJ"
    deidgroup$trumpvote[700] <- 38.6
    deidgroup$county[701] <- "Kleberg_TX"
    deidgroup$trumpvote[701] <- 46
    deidgroup$county[702] <- "Montgomery_IN"
    deidgroup$trumpvote[702] <- 73.2
    deidgroup$county[703] <- "Kalamazoo_MI"
    deidgroup$trumpvote[703] <- 40.5
    deidgroup$county[704] <- "Linn_IA"
    deidgroup$trumpvote[704] <- 42
    deidgroup$county[705] <- "Boulder_CO"
    deidgroup$trumpvote[705] <- 21.9
    deidgroup$county[706] <-"Lancaster_NE"
    deidgroup$trumpvote[706] <- 46.6
    deidgroup$county[707] <- "Lehigh_PA"
    deidgroup$trumpvote[707] <- 45.9
    deidgroup$county[708] <- "Utah_UT"
    deidgroup$trumpvote[708] <- 51.5
    deidgroup$county[709] <- "Yolo_CA"
    deidgroup$trumpvote[709] <- 26
    deidgroup$county[710] <- "Vigo_IN"
    deidgroup$trumpvote[710] <- 55.4
    deidgroup$county[711] <- "Clay_MN"
    deidgroup$trumpvote[711] <- 46.5
    deidgroup$county[712] <- "Alaska"
    deidgroup$trumpvote[712] <- 51.28
    deidgroup$county[713] <- "Cheshire_NH"
    deidgroup$trumpvote[713] <- 41
    deidgroup$county[714] <- "Lycoming_PA"
    deidgroup$trumpvote[714] <- 70.5
    deidgroup$county[715] <- "Dane_WI"
    deidgroup$trumpvote[715] <- 23.4
    deidgroup$county[716] <- "Allen_IN"
    deidgroup$trumpvote[716] <- 57.5
    deidgroup$county[717] <- "Lycoming_PA"
    deidgroup$trumpvote[717] <- 70.5
    deidgroup$county[718] <- "Gallatin_MT"
    deidgroup$trumpvote[718] <- 44.6
    deidgroup$county[719] <- "Sangamon_IL"
    deidgroup$trumpvote[719] <- 51.6
    deidgroup$county[720] <- "Anne Arundel_MD"
    deidgroup$trumpvote[720] <- 47.1
    deidgroup$county[721] <- "Winona_MN"
    deidgroup$trumpvote[721] <- 46.9
    deidgroup$county[722] <- "New York_NY"
    deidgroup$trumpvote[722] <- 10
    deidgroup$county[723] <- "Grayson_TX"
    deidgroup$trumpvote[723] <- 74.9
    deidgroup$county[724] <- "Hudson_NJ"
    deidgroup$trumpvote[724] <- 22.6
    deidgroup$county[725] <- "Outagamie_WI"
    deidgroup$trumpvote[725] <- 54.2
    deidgroup$county[726] <- "Greene_MO"
    deidgroup$trumpvote[726] <- 60.6
    deidgroup$county[727] <- "New London_CT"
    deidgroup$trumpvote[727] <- 43.8
    deidgroup$county[728] <- "Schenectady_NY"
    deidgroup$trumpvote[728] <- 44.2
    deidgroup$county[729] <- "Luzerne_PA"
    deidgroup$trumpvote[729] <- 58.4
    deidgroup$county[730] <- "HampdenCounty_MA"
    deidgroup$trumpvote[730] <- 39
    deidgroup$county[731] <- "Stearns_MN"
    deidgroup$trumpvote[731] <- 60.3
    deidgroup$county[732] <- "Webb_TX"
    deidgroup$trumpvote[732] <- 22.8
    deidgroup$county[733] <- "Lane_OR"
    deidgroup$trumpvote[733] <- 36.6
    deidgroup$county[734] <- "Eau Claire_WI"
    deidgroup$trumpvote[734] <- 43.1
    deidgroup$county[735] <- "La Crosse_WI"
    deidgroup$trumpvote[735] <- 42
    deidgroup$county[736] <- "Peoria_IL"
    deidgroup$trumpvote[736] <- 45.6
    deidgroup$county[737] <- "Coconino_AZ"
    deidgroup$trumpvote[737] <- 36.9
    deidgroup$county[738] <- "Wichita_TX"
    deidgroup$trumpvote[738] <- 72.8
    deidgroup$county[739] <- "Brazos_TX"
    deidgroup$trumpvote[739] <- 58.5
    deidgroup$county[740] <- "Washtenaw_MI"
    deidgroup$trumpvote[740] <- 26.9
    deidgroup$county[741] <- "Worcester_MA"
    deidgroup$trumpvote[741] <- 41.2
    deidgroup$county[742] <- "Providence_RI"
    deidgroup$trumpvote[742] <- 37.6
    deidgroup$county[743] <- "Coles_IL"
    deidgroup$trumpvote[743] <- 60.2
    deidgroup$county[744] <- "Kennebec_ME"
    deidgroup$trumpvote[744] <- 48.1
    deidgroup$county[745] <- "Lancaster_PA"
    deidgroup$trumpvote[745] <- 57.3
    deidgroup$county[746] <- "Cass_ND"
    deidgroup$trumpvote[746] <- 50.4
    deidgroup$county[747] <- "Onondaga_NY"
    deidgroup$trumpvote[747] <- 40.8
    deidgroup$county[748] <- "Ward_ND"
    deidgroup$trumpvote[748] <- 69.2
    deidgroup$county[749] <- "Story_IA"
    deidgroup$trumpvote[749] <- 39.1
    deidgroup$county[750] <- "Cleveland_OK"
    deidgroup$trumpvote[750] <- 57.1
    deidgroup$county[751] <- "Buchanan_MO"
    deidgroup$trumpvote[751] <- 59.9
    deidgroup$county[752] <- "Orange_CA"
    deidgroup$trumpvote[752] <- 44.8
    deidgroup$county[753] <- "Ada_ID"
    deidgroup$trumpvote[753] <- 47.9
    deidgroup$county[754] <- "Denver_CO"
    deidgroup$trumpvote[754] <- 18.8
    deidgroup$county[755] <- "Buffalo_NE"
    deidgroup$trumpvote[755] <- 70.4
    deidgroup$county[756] <- "Lake_IN"
    deidgroup$trumpvote[756] <- 37.7
    deidgroup$county[757] <- "Payne_OK"
    deidgroup$trumpvote[757] <- 60
    deidgroup$county[758] <- "Doña Ana_NM"
    deidgroup$trumpvote[758] <- 35.9
    deidgroup$county[759] <- "Alaska"
    deidgroup$trumpvote[759] <- 51.28
    deidgroup$county[760] <- "Worcester_MA"
    deidgroup$trumpvote[760] <- 41.2
    deidgroup$county[761] <- "Lake_IN"
    deidgroup$trumpvote[761] <- 37.7
    deidgroup$county[762] <- "Douglas_WI"
    deidgroup$trumpvote[762] <- 43.5
    deidgroup$county[763] <- "Winona_MN"
    deidgroup$trumpvote[763] <- 46.9
    deidgroup$county[764] <- "Albany_NY"
    deidgroup$trumpvote[764] <- 35.2
    deidgroup$county[765] <- "Kent_DE"
    deidgroup$trumpvote[765] <- 49.8
    deidgroup$county[766] <- "Comanche_OK"
    deidgroup$trumpvote[766] <- 58.9
    deidgroup$county[767] <- "Monroe_IN"
    deidgroup$trumpvote[767] <- 35.6
    deidgroup$county[768] <- "Mesa_CO"
    deidgroup$trumpvote[768] <- 64.3
    deidgroup$county[769] <- "QueensCounty_NY"
    deidgroup$trumpvote[769] <- 22
    deidgroup$county[770] <- "Washington_UT"
    deidgroup$trumpvote[770] <- 68.6
    deidgroup$county[771] <- "Stark_ND"
    deidgroup$trumpvote[771] <- 80.2
    deidgroup$county[772] <- "Nez Perce_ID"
    deidgroup$trumpvote[772] <- 62.2
    deidgroup$county[773] <- "Gratiot_MI"
    deidgroup$trumpvote[773] <- 60.1
    deidgroup$county[774] <- "Brown_SD"
    deidgroup$trumpvote[774] <- 59.7
    deidgroup$county[775] <- "Kalamazoo_MI"
    deidgroup$trumpvote[775] <- 40.5
    deidgroup$county[776] <- "Riverside_CA"
    deidgroup$trumpvote[776] <- 46.7
    deidgroup$county[777] <- "Jackson_OR"
    deidgroup$trumpvote[777] <- 51.1
    deidgroup$county[778] <- "Denton_TX"
    deidgroup$trumpvote[778] <- 57.7
    deidgroup$county[779] <- "Ector_TX"
    deidgroup$trumpvote[779] <- 68.7
    deidgroup$county[780] <- "Victoria_TX"
    deidgroup$trumpvote[780] <- 68.5
    deidgroup$county[781] <- "Douglas_KS"
    deidgroup$trumpvote[781] <- 29.7
    deidgroup$county[782] <- "Blue Earth_MN"
    deidgroup$trumpvote[782] <- 47.1
    deidgroup$county[783] <- "Dubuque_IA"
    deidgroup$trumpvote[783] <- 47.7
    deidgroup$county[784] <- "Macon_IL"
    deidgroup$trumpvote[784] <- 56.6
    deidgroup$county[785] <- "Cache_UT"
    deidgroup$trumpvote[785] <- 46.7
    deidgroup$county[786] <- "Tulsa_OK"
    deidgroup$trumpvote[786] <- 58.4
    deidgroup$county[787] <- "Sacramento_CA"
    deidgroup$trumpvote[787] <- 34.9
    deidgroup$county[788] <- "Smith_TX"
    deidgroup$trumpvote[788] <- 70.5
    deidgroup$county[789] <- "Larimer_TX"
    deidgroup$trumpvote[789] <- 42.8
    deidgroup$county[790] <- "Portage_WI"
    deidgroup$trumpvote[790] <- 45.4
    deidgroup$county[791] <- "Marquette_MI"
    deidgroup$trumpvote[791] <- 44.5
    deidgroup$county[792] <- "Vanderburgh_IN"
    deidgroup$trumpvote[792] <- 56.2
    deidgroup$county[793] <- "Lubbock_TX"
    deidgroup$trumpvote[793] <- 66.9
    deidgroup$county[794] <- "Washtenaw_MI"
    deidgroup$trumpvote[794] <- 26.9
    deidgroup$county[795] <- "Androscoggin_ME"
    deidgroup$trumpvote[795] <- 50.9
    deidgroup$county[796] <- "El Paso_CO"
    deidgroup$trumpvote[796] <- 56.3
    deidgroup$county[797] <- "El Paso_CO"
    deidgroup$trumpvote[797] <- 56.3
    deidgroup$county[798] <- "Pima_AZ"
    deidgroup$trumpvote[798] <- 41
    deidgroup$county[799] <- "Winnebago_IL"
    deidgroup$trumpvote[799] <- 47.7
  
  deidgroup$county[800] <- "Cumberland_ME"
  deidgroup$trumpvote[800] <- 33.7
  deidgroup$county[801] <- "Tippecanoe_IN"
  deidgroup$trumpvote[801] <- 49.6
  deidgroup$county[802] <- "Santa Fe_NM"
  deidgroup$trumpvote[802] <- 20.2
  deidgroup$county[803] <- "CookCounty_IL"
  deidgroup$trumpvote[803] <- 21.4
  deidgroup$county[804] <- "Hinds_MS"
  deidgroup$trumpvote[804] <- 26.9
  deidgroup$county[805] <- "Shelby_TN"
  deidgroup$trumpvote[805] <- 34.6
  deidgroup$county[806] <- "Limestone_AL"
  deidgroup$trumpvote[806] <- 73.2
  deidgroup$county[807] <- "OrleansParish_LA"
  deidgroup$trumpvote[807] <- 14.7
  deidgroup$county[808] <- "Shelby_TN" 
  deidgroup$trumpvote[808] <- 34.6
  deidgroup$county[809] <- "JeffersonCounty_KY" 
  deidgroup$trumpvote[809] <- 40.7
  deidgroup$county[810] <- "Talladega_AL"
  deidgroup$trumpvote[810] <- 62
  deidgroup$county[811] <- "Davidson_TN"
  deidgroup$trumpvote[811] <- 34.3
  deidgroup$county[812] <- "Charleston_SC"
  deidgroup$trumpvote[812] <- 42.8
  deidgroup$county[813] <- "Mecklenburg_NC"
  deidgroup$trumpvote[813] <- 33.4
  deidgroup$county[814] <- "Davidson_TN"
  deidgroup$trumpvote[814] <- 34.3
  deidgroup$county[815] <- "Hampton_VA"
  deidgroup$trumpvote[815] <- 29
  deidgroup$county[816] <- "Norfolk City_VA"
  deidgroup$trumpvote[816] <- 26.4
  deidgroup$county[817] <- "Polk_FL"
  deidgroup$trumpvote[817] <- 55.4
  deidgroup$county[818] <- "Davidson_TN"
  deidgroup$trumpvote[818] <- 34.3
  deidgroup$county[819] <- "East Baton Rouge_LA"
  deidgroup$trumpvote[819] <- 43.1
  deidgroup$county[820] <- "Fayette_KY"
  deidgroup$trumpvote[820] <- 41.8
  deidgroup$county[821] <- "OrleansParish_LA"
  deidgroup$trumpvote[821] <- 14.7
  deidgroup$county[822] <- "Volusia_FL"
  deidgroup$trumpvote[822] <- 54.8
  deidgroup$county[823] <- "Fulton_GA"
  deidgroup$trumpvote[823] <- 27.1
  deidgroup$county[824] <- "HillsboroughCounty_FL" 
  deidgroup$trumpvote[824] <- 44.7
  deidgroup$county[825] <- "Lee_FL"
  deidgroup$trumpvote[825] <- 58.7
  deidgroup$county[826] <- "East Baton Rouge_LA"
  deidgroup$trumpvote[826] <- 43.1
  deidgroup$county[827] <- "MontgomeryCounty_AL"
  deidgroup$trumpvote[827] <- 35.9
  deidgroup$county[828] <- "Durham_NC"
  deidgroup$trumpvote[828] <- 18.5
  deidgroup$county[829] <- "Montgomery_TN"
  deidgroup$trumpvote[829] <- 56.4
  deidgroup$county[830] <- "Richmond City_VA"
  deidgroup$trumpvote[830] <- 15
  deidgroup$county[831] <- "Richmond_GA"
  deidgroup$trumpvote[831] <- 32.6
  deidgroup$county[832] <- "Norfolk City_VA"
  deidgroup$trumpvote[832] <- 26.4
  deidgroup$county[833] <- "Pulaski_AR"
  deidgroup$trumpvote[833] <- 38.4
  deidgroup$county[834] <- "Richland_SC"
  deidgroup$trumpvote[834] <- 31.1
  deidgroup$county[835] <- "SpartanburgCounty_SC"
  deidgroup$trumpvote[835] <- 63
  deidgroup$county[836] <- "BrowardCounty_FL"
  deidgroup$trumpvote[836] <- 31.5
  deidgroup$county[837] <- "Wake_NC"
  deidgroup$trumpvote[837] <- 37.9
  deidgroup$county[838] <- "Jefferson_AL"
  deidgroup$trumpvote[838] <- 45
  deidgroup$county[839] <- "FultonCounty_GA"
  deidgroup$trumpvote[839] <- 27.1
  deidgroup$county[840] <- "Mecklenburg_NC"
  deidgroup$trumpvote[840] <- 33.4
  deidgroup$county[841] <- "Charleston_SC"
  deidgroup$trumpvote[841] <- 42.8
  deidgroup$county[842] <- "Madison_AL"
  deidgroup$trumpvote[842] <- 55.9
  deidgroup$county[843] <- "Knox_TN"
  deidgroup$trumpvote[843] <- 59
  deidgroup$county[844] <- "DeKalb_GA"
  deidgroup$trumpvote[844] <- 16.1
  deidgroup$county[845] <- "FultonCounty_GA"
  deidgroup$trumpvote[845] <- 27.1
  deidgroup$county[846] <- "Miami-Dade_FL"
  deidgroup$trumpvote[846] <- 34.1
  deidgroup$county[847] <- "Richmond_GA"
  deidgroup$trumpvote[847] <- 32.6
  deidgroup$county[848] <- "Miami-Dade_FL"
  deidgroup$trumpvote[848] <- 34.1
  deidgroup$county[849] <- "Shelby_TN"
  deidgroup$trumpvote[849] <- 34.6
  deidgroup$county[850] <- "FultonCounty_GA"
  deidgroup$trumpvote[850] <- 27.1

    deidgroup$county[851] <- "OrleansParish_LA"
    deidgroup$trumpvote[851] <- 14.7 
    deidgroup$county[852]<- "DuvalCounty_FL" 
    deidgroup$trumpvote[852] <- 49 
    deidgroup$county[853] <-"JeffersonCounty_KY" 
    deidgroup$trumpvote[853] <- 40.7 
    deidgroup$county[854]<- "HillsboroughCounty_FL" 
    deidgroup$trumpvote[854] <- 44.7
    deidgroup$county[855] <- "MarionCounty_FL"
    deidgroup$trumpvote[855] <- 61.7
    deidgroup$county[856] <- "OrleansParish_LA"
    deidgroup$trumpvote[856] <- 14.7 
    deidgroup$county[857] <- "MontgomeryCounty_AL"
    deidgroup$trumpvote[857] <- 35.9 
    deidgroup$county[858]<- "FultonCounty_GA"
    deidgroup$trumpvote[858] <- 27.1 
    deidgroup$county[859] <- "GuilfordCounty_NC"
    deidgroup$trumpvote[859] <- 38.7 
    deidgroup$county[860] <- "GuilfordCounty_NC"
    deidgroup$trumpvote[860] <- 38.7  
    deidgroup$county[861] <- "NewHanoverCounty_NC" 
    deidgroup$trumpvote[861] <- 50.3  
    deidgroup$county[862] <- "SpartanburgCounty_SC"
    deidgroup$trumpvote[862] <- 63 
    deidgroup$county[863] <- "PinellasCounty_FL" 
    deidgroup$trumpvote[863] <- 48.6 
    deidgroup$county[864] <- "BrowardCounty_FL" 
    deidgroup$trumpvote[864] <- 31.5
    deidgroup$county[865] <- "DauphinCounty_PA" 
    deidgroup$trumpvote[865] <- 46.6
    deidgroup$county[866] <- "CookCounty_IL" 
    deidgroup$trumpvote[866] <- 21.4
    deidgroup$county[867] <- "OklahomaCounty_OK"
    deidgroup$trumpvote[867] <- 51.7 
    deidgroup$county[868] <- "NewYorkCounty_NY"
    deidgroup$trumpvote[868] <- 10 
    deidgroup$county[869] <-"CookCounty_IL" 
    deidgroup$trumpvote[869] <- 21.4  
    deidgroup$county[870] <-"SuffolkCounty_MA" 
    deidgroup$trumpvote[870] <-16.5 
    deidgroup$county[871] <- "PhiladelphiaCounty_PA" 
    deidgroup$trumpvote[871] <- 15.5  
    deidgroup$county[872] <- "WestchesterCounty_NY" 
    deidgroup$trumpvote[872] <- 32.1  
    deidgroup$county[873] <- "KingsCounty_NY" 
    deidgroup$trumpvote[873] <- 17.9
    deidgroup$county[874] <- "DistrictofColumbia_WashingtonDC" 
    deidgroup$trumpvote[874] <- 4.1 
    deidgroup$county[875] <- "SaratogaCounty_NY" 
    deidgroup$trumpvote[875] <- 49.1
    deidgroup$county[876] <- "NorfolkCounty_MA" 
    deidgroup$trumpvote[876] <- 33.3 
    deidgroup$county[877] <-"SuffolkCounty_MA"
    deidgroup$trumpvote[877] <- 16.5 
    deidgroup$county[878] <-"AlamedaCounty_CA"
    deidgroup$trumpvote <- 15.6 
    deidgroup$county[879] <- "BaltimoreCounty_MD" 
    deidgroup$trumpvote[879] <- 39.1  
    deidgroup$county[880] <- "RamseyCounty_MN"
    deidgroup$trumpvote[880] <- 26.3 
    deidgroup$county[881] <- "SuffolkCounty_MA"
    deidgroup$trumpvote[881] <- 16.5 
    deidgroup$county[882] <- "MonroeCounty_NY"
    deidgroup$trumpvote[882] <- 40.3 
    deidgroup$county[883] <- "LosAngelesCounty_CA"
    deidgroup$trumpvote[883] <- 23.4 
    deidgroup$county[884] <- "PhiladelphiaCounty_PA" 
    deidgroup$trumpvote[884] <- 15.5 
    deidgroup$county[885] <- "SanFranciscoCounty_CA"
    deidgroup$trumpvote[885] <- 9.9 
    deidgroup$county[886] <- "St.LouisCounty_MO" 
    deidgroup$trumpvote[886] <- 39.5 
    deidgroup$county[887] <- "CuyahogaCounty_OH" 
    deidgroup$trumpvote[887] <- 30.8 
    deidgroup$county[888] <- "HarrisCounty_TX" 
    deidgroup$trumpvote[888] <- 41.8  
    deidgroup$county[889] <- "RamseyCounty_MN"
    deidgroup$trumpvote[889] <- 26.3 
    deidgroup$county[890] <- "KingsCounty_NY"
    deidgroup$trumpvote[890] <- 17.9  
    deidgroup$county[891] <- "Lake County_IN"
    deidgroup$trumpvote[891] <- 37.7 
    deidgroup$county[892] <- "HennepinCounty_MN"
    deidgroup$trumpvote[892] <- 28.5
    deidgroup$county[893] <- "BernalilloCounty_NM" 
    deidgroup$trumpvote[893] <- 34.5
    deidgroup$county[894] <- "KingCounty_WA" 
    deidgroup$trumpvote[894] <- 21.4 
    deidgroup$county[895] <- "HudsonCounty_NJ"
    deidgroup$trumpvote[895] <- 22.6 
    deidgroup$county[896]  <- "ClarkCounty_NV"
    deidgroup$trumpvote[896] <- 41.8 
    deidgroup$county[897] <- "DouglasCounty_NE"
    deidgroup$trumpvote[897] <- 46.5 
    deidgroup$county[898] <- "LosAngelesCounty_CA" 
    deidgroup$trumpvote[898] <- 23.4 
    deidgroup$county[899] <- "NewYorkCounty_NY" 
    deidgroup$trumpvote[899] <- 10 
    deidgroup$county[900] <- "ClarkCounty_NV"
    deidgroup$trumpvote[900] <- 41.8 
    
  deidgroup$county[901] <- "JacksonCounty_MO"
  deidgroup$trumpvote[901] <- 39
  deidgroup$county[902] <- "BexarCounty_TX"
  deidgroup$trumpvote[902] <- 41
  deidgroup$county[903] <- "MahoningCounty_OH"
  deidgroup$trumpvote[903] <- 47
  deidgroup$county[904] <- "DenverCounty_CO"
  deidgroup$trumpvote[904] <- 19
  deidgroup$county[905] <- "FranklinCounty_OH"
  deidgroup$trumpvote[905] <- 35
  deidgroup$county[906] <- "BaltimoreCounty_MD"
  deidgroup$trumpvote[906] <- 39
  deidgroup$county[907] <- "HarrisonCounty_TX"
  deidgroup$trumpvote[907] <- 42
  deidgroup$county[908] <- "BronxCounty_NY"
  deidgroup$trumpvote[908] <- 9.6
  deidgroup$county[909] <- "MissoulaCounty_MT"
  deidgroup$trumpvote[909] <- 38
  deidgroup$county[910] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[910] <- 10
  deidgroup$county[911] <- "MultnomahCounty_OR"
  deidgroup$trumpvote[911] <- 17.6
  deidgroup$county[912] <- "SanDiegoCounty_CA"
  deidgroup$trumpvote[912] <- 38
  deidgroup$county[913] <- "SuffolkCounty_MA"
  deidgroup$trumpvote[913] <- 16.5
  deidgroup$county[914] <- "MaricopaCounty_AZ"
  deidgroup$trumpvote[914] <- 49
  deidgroup$county[915] <- "KingCounty_WA"
  deidgroup$trumpvote[915] <- 22
  deidgroup$county[916] <- "KingsCounty_NY"
  deidgroup$trumpvote[916] <- 18
  deidgroup$county[917] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[917] <- 10
  deidgroup$county[918] <- "CookCounty_IL"
  deidgroup$trumpvote[918] <- 21.4
  deidgroup$county[919] <- "SuffolkCounty_MA"
  deidgroup$trumpvote[919] <- 16.5
  deidgroup$county[920] <- "PascoCounty_FL"
  deidgroup$trumpvote[920] <- 59
  deidgroup$county[921] <- "Washington_DC"
  deidgroup$trumpvote[921] <- 4
  deidgroup$county[922] <- "CamdenCounty_NJ"
  deidgroup$trumpvote[922] <- 32
  deidgroup$county[923] <- "HarrisCounty_TX"
  deidgroup$trumpvote[923] <- 42
  deidgroup$county[924] <- "HarrisCounty_TX"
  deidgroup$trumpvote[924] <- 42
  deidgroup$county[925] <- "PhiladelphiaCounty_PA"
  deidgroup$trumpvote[925] <- 15.5
  deidgroup$county[926] <- "HampdenCounty_MA"
  deidgroup$trumpvote[926] <- 39
  deidgroup$county[927] <- "HowardCounty_IN"
  deidgroup$trumpvote[927] <- 64.4
  deidgroup$county[928] <- "DenverCounty_CO"
  deidgroup$trumpvote[928] <- 19
  deidgroup$county[929] <- "CuyahogaCounty_OH"
  deidgroup$trumpvote[929] <- 31
  deidgroup$county[930] <- "St.LouisCounty_MO"
  deidgroup$trumpvote[930] <- 39.5
  deidgroup$county[931] <- "ElPasoCounty_TX"
  deidgroup$trumpvote[931] <- 26
  deidgroup$county[932] <- "SedgwickCounty_KA"
  deidgroup$trumpvote[932] <- 56
  deidgroup$county[933] <- "QueensCounty_NY"
  deidgroup$trumpvote[933] <- 22
  deidgroup$county[934] <- "DeKalbCounty_IL"
  deidgroup$trumpvote[934] <- 45
  deidgroup$county[935] <- "KingCounty_WA"
  deidgroup$trumpvote[935] <- 22
  deidgroup$county[936] <- "LosAngelesCounty_CA"
  deidgroup$trumpvote[936] <- 23.4
  deidgroup$county[937] <- "SaltLakeCounty_UT"
  deidgroup$trumpvote[937] <- 32.6
  deidgroup$county[938] <- "RichmondCounty_NY"
  deidgroup$trumpvote[938] <- 57
  deidgroup$county[939] <- "WashoeCounty_NV"
  deidgroup$trumpvote[939] <- 45
  deidgroup$county[940] <- "BaltimoreCounty_MD"
  deidgroup$trumpvote[940] <- 39
  deidgroup$county[941] <- "KingsCounty_NY"
  deidgroup$trumpvote[941] <- 18
  deidgroup$county[942] <- "LosAngelesCounty_CA"
  deidgroup$trumpvote[942] <- 23.4
  deidgroup$county[943] <- "MarionCounty_IN"
  deidgroup$trumpvote[943] <- 36
  deidgroup$county[944] <- "TravisCounty_TX"
  deidgroup$trumpvote[944] <- 27.4
  deidgroup$county[945] <- "SuffolkCounty_MA"
  deidgroup$trumpvote[945] <- 16.5
  deidgroup$county[946] <- "MilwaukeeCounty_WI"
  deidgroup$trumpvote[946] <- 29
  deidgroup$county[947] <- "KingsCounty_NY"
  deidgroup$trumpvote[947] <- 18
  deidgroup$county[948] <- "TulsaCounty_OK"
  deidgroup$trumpvote[948] <- 58.4
  deidgroup$county[949] <- "RamseyCounty_MN"
  deidgroup$trumpvote[949] <- 26
  deidgroup$county[950] <- "LucasCounty_OH"
  deidgroup$trumpvote[950] <- 39
  deidgroup$county[951] <- "PierceCounty_WA"
  deidgroup$trumpvote[951] <- 42
  deidgroup$county[952] <- "TarrantCounty_TX"
  deidgroup$trumpvote[952] <- 52
  deidgroup$county[953] <- "SanFranciscoCounty_CA"
  deidgroup$trumpvote[953] <- 9.4
  deidgroup$county[954] <- "GeneseeCounty_MI"
  deidgroup$trumpvote[954] <- 43
  deidgroup$county[955] <- "CookCounty_IL"
  deidgroup$trumpvote[955] <- 21.4
  deidgroup$county[956] <- "BaltimoreCounty_MD"
  deidgroup$trumpvote[956] <- 39
  deidgroup$county[957] <- "SanDiegoCounty_CA"
  deidgroup$trumpvote[957] <- 38
  deidgroup$county[958] <- "FresnoCounty_CA"
  deidgroup$trumpvote[958] <- 45.5
  deidgroup$county[959] <- "YellowstoneCounty_MT"
  deidgroup$trumpvote[959] <- 59.6
  deidgroup$county[960] <- "ProvidenceCounty_RI"
  deidgroup$trumpvote[960] <- 37
  deidgroup$county[961] <- "AlleghenyCounty_PA"
  deidgroup$trumpvote[961] <- 40
  deidgroup$county[962] <- "FairfieldCounty_CT"
  deidgroup$trumpvote[962] <- 38
  deidgroup$county[963] <- "MilwaukeeCounty_WI"
  deidgroup$trumpvote[963] <- 29
  deidgroup$county[964] <- "LosAngelesCounty_CA"
  deidgroup$trumpvote[964] <- 23.4
  deidgroup$county[965] <- "CookCounty_IL"
  deidgroup$trumpvote[965] <- 21.4
  deidgroup$county[966] <- "FairbanksNorthernStarBourough_Alaska"
  deidgroup$trumpvote[966] <- 51.28
  deidgroup$county[967] <- "BooneCounty_MO"
  deidgroup$trumpvote[967] <- 43.4
  deidgroup$county[968] <- "FairfieldCounty_CT"
  deidgroup$trumpvote[968] <- 38
  deidgroup$county[969] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[969] <- 10
  deidgroup$county[970] <- "CookCounty_IL"
  deidgroup$trumpvote[970] <- 21.4
  deidgroup$county[971] <- "LawrenceCounty_PA"
  deidgroup$trumpvote[971] <- 62.4
  deidgroup$county[972] <- "PhiladephiaCounty_PA"
  deidgroup$trumpvote[972] <- 15.5
  deidgroup$county[973] <- "PhiladephiaCounty_PA"
  deidgroup$trumpvote[973] <- 15.5
  deidgroup$county[974] <- "ShawneeCounty_KA"
  deidgroup$trumpvote[974] <- 48
  deidgroup$county[975] <- "WayneCounty_MI"
  deidgroup$trumpvote[975] <- 29.5
  deidgroup$county[976] <- "ErieCounty_NY"
  deidgroup$trumpvote[976] <- 45.4
  deidgroup$county[977] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[977] <- 10
  deidgroup$county[978] <- "Washington_DC"
  deidgroup$trumpvote[978] <- 4
  deidgroup$county[979] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[979] <- 10
  deidgroup$county[980] <- "HamiltonCounty_OH"
  deidgroup$trumpvote[980] <- 43
  deidgroup$county[981] <- "SanFranciscoCounty_CA"
  deidgroup$trumpvote[981] <- 9.4
  deidgroup$county[982] <- "MilwaukeeCounty_WI"
  deidgroup$trumpvote[982] <- 29
  deidgroup$county[983] <- "HonoluluCounty_HI"
  deidgroup$trumpvote[983] <- 32
  deidgroup$county[984] <- "CookCounty_IL"
  deidgroup$trumpvote[984] <- 21.4
  deidgroup$county[985] <- "CookCounty_IL"
  deidgroup$trumpvote[985] <- 21.4
  deidgroup$county[986] <- "SuffolkCounty_MA"
  deidgroup$trumpvote[986] <- 16.5
  deidgroup$county[987] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[987] <- 10
  deidgroup$county[988] <- "JeffersonCounty_TX"
  deidgroup$trumpvote[988] <- 49
  deidgroup$county[989] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[989] <- 10
  deidgroup$county[990] <- "McLeanCounty_IL"
  deidgroup$trumpvote[990] <- 47
  deidgroup$county[991] <- "AlleghenyCounty_PA"
  deidgroup$trumpvote[991] <- 40
  deidgroup$county[992] <- "NewYorkCounty_NY"
  deidgroup$trumpvote[992] <- 10
  deidgroup$county[993] <- "AlleghenyCounty_PA"
  deidgroup$trumpvote[993] <- 40
  deidgroup$county[994] <- "SanDiegoCounty_CA"
  deidgroup$trumpvote[994] <- 38
  deidgroup$county[995] <- "HonoluluCounty_HI"
  deidgroup$trumpvote[995] <- 32
  deidgroup$county[996] <- "RichmondCounty_NY"
  deidgroup$trumpvote[996] <- 57
  deidgroup$county[997] <- "St.JosephCounty_IN"
  deidgroup$trumpvote[997] <- 47.5
  deidgroup$county[998] <- "BronxCounty_NY"
  deidgroup$trumpvote[998] <- 9.6
  deidgroup$county[999] <- "BoulderCounty_CO"
  deidgroup$trumpvote[999] <- 22
  deidgroup$county[1000] <- "SuffolkCounty_MA"
  deidgroup$trumpvote[1000] <- 16.5
  
    deidgroup$county[1001] <- "Essex_NJ"
    deidgroup$trumpvote[1001] <- 20.7
    deidgroup$county[1002] <- "Worcester_MA"
    deidgroup$trumpvote[1002] <- 41.2
    deidgroup$county[1003] <- "Hennepin_MN"
    deidgroup$trumpvote[1003] <- 28.5
    deidgroup$county[1004] <- "Santa Clara_CA"
    deidgroup$trumpvote[1004] <- 20.9
    deidgroup$county[1005] <- "Marion_IN"
    deidgroup$trumpvote[1005] <- 36.2
    deidgroup$county[1006] <- "Washington_DC"
    deidgroup$trumpvote[1006] <- 4.1
    deidgroup$county[1007] <- "Allegheny_PA"
    deidgroup$trumpvote[1007] <- 40
    deidgroup$county[1008] <- "Multnomah_OR"
    deidgroup$trumpvote[1008] <- 17.6
    deidgroup$county[1009] <- "Middlesex_MA"
    deidgroup$trumpvote[1009] <- 28.2
    deidgroup$county[1010] <- "Summit_OH"
    deidgroup$trumpvote[1010] <- 43.8
    deidgroup$county[1011] <- "Suffolk_MA"
    deidgroup$trumpvote[1011] <- 16.5
    deidgroup$county[1012] <- "Cook_IL"
    deidgroup$trumpvote[1012] <- 21.4
    deidgroup$county[1013] <- "QueensCounty_NY"
    deidgroup$trumpvote[1013] <- 22
    deidgroup$county[1014] <- "Essex_NJ"
    deidgroup$trumpvote[1014] <- 20.7
    deidgroup$county[1015] <- "Los Angeles_CA"
    deidgroup$trumpvote[1015] <- 23.4
    deidgroup$county[1016] <- "Wayne_MI"
    deidgroup$trumpvote[1016] <- 29.4
    deidgroup$county[1017] <- "Perry_AL"
    deidgroup$trumpvote[1017] <- 26.7
    deidgroup$county[1018] <- "Knox_KY"
    deidgroup$trumpvote[1018] <- 82.3
    deidgroup$county[1019] <- "Duval_FL"
    deidgroup$trumpvote[1019] <- 49
    deidgroup$county[1020] <- "Greene_AR"
    deidgroup$trumpvote[1020] <- 73.5
    deidgroup$county[1021] <- "Pickens_SC"
    deidgroup$trumpvote[1021] <- 73.9
    deidgroup$county[1022] <- "Jefferson_AL"
    deidgroup$trumpvote[1022] <- 45
    deidgroup$county[1023] <- "Cook_IL"
    deidgroup$trumpvote[1023] <- 21.4
    deidgroup$county[1024] <- "Cascade_MT"
    deidgroup$trumpvote[1024] <- 57
    deidgroup$county[1025] <- "Winnebago_WI"
    deidgroup$trumpvote[1025] <- 50.6
    deidgroup$county[1026] <- "Kent_MI"
    deidgroup$trumpvote[1026] <- 48.3
    deidgroup$county[1027] <- "Hancock_IA"
    deidgroup$trumpvote[1027] <- 68.3
    deidgroup$county[1028] <- "Jefferson_CO"
    deidgroup$trumpvote[1028] <- 42.2
    deidgroup$county[1029] <- "Mahaska_IA"
    deidgroup$trumpvote[1029] <- 70.6
    deidgroup$county[1030] <- "Erie_NY"
    deidgroup$trumpvote[1030] <- 45.4
    deidgroup$county[1031] <- "La Crosse_WI"
    deidgroup$trumpvote[1031] <- 42
    deidgroup$county[1032] <- "Erie_NY"
    deidgroup$trumpvote[1032] <- 45.4
    deidgroup$county[1033] <- "Washington_DC"
    deidgroup$trumpvote[1033] <- 4.1
    deidgroup$county[1034] <- "Oklahoma_OK"
    deidgroup$trumpvote[1034] <- 51.7
    deidgroup$county[1035] <- "Smith_TX"
    deidgroup$trumpvote[1035] <- 70.5
    deidgroup$county[1036] <- "Jefferson_WI"
    deidgroup$trumpvote[1036] <- 55.3
    deidgroup$county[1037] <- "Cumberland_ME"
    deidgroup$trumpvote[1037] <- 33.7
    deidgroup$county[1038] <- "Madison_ID"
    deidgroup$trumpvote[1038] <- 57
    deidgroup$county[1039] <- "Muskogee_OK"
    deidgroup$trumpvote[1039] <- 62.1
    deidgroup$county[1040] <- "Riverside_CA"
    deidgroup$trumpvote[1040] <- 46.7
    deidgroup$county[1041] <- "Jackson_MO"
    deidgroup$trumpvote[1041] <- 39
    deidgroup$county[1042] <- "Greenville_SC"
    deidgroup$trumpvote[1042] <- 59.4
    deidgroup$county[1043] <- "Polk_FL"
    deidgroup$trumpvote[1043] <- 55.4
    deidgroup$county[1044] <- "Marshall_MS"
    deidgroup$trumpvote[1044] <- 44.4
    deidgroup$county[1045] <- "Rhea_TN"
    deidgroup$trumpvote[1045] <- 79
    deidgroup$county[1046] <- "Hertford_NC"
    deidgroup$trumpvote[1046] <- 30.5
    deidgroup$county[1047] <- "Franklin_GA"
    deidgroup$trumpvote[1047] <- 83.2
    deidgroup$county[1048] <- "Cherokee_GA"
    deidgroup$trumpvote[1048] <- 72.7
    deidgroup$county[1049] <- "Barbour_WV"
    deidgroup$trumpvote[1049] <- 74.9
    deidgroup$county[1050] <- "Greene_TN"
    deidgroup$trumpvote[1050] <- 78.9
    deidgroup$county[1051] <- "Washington_VA"
    deidgroup$trumpvote[1051] <- 75
    deidgroup$county[1052] <- "Stephens_GA"
    deidgroup$trumpvote[1052] <- 78.7
    deidgroup$county[1053] <- "Tazewell_VA"
    deidgroup$trumpvote[1053] <- 82
    deidgroup$county[1054] <- "Tippah_MS"
    deidgroup$trumpvote[1054] <- 78.6
    deidgroup$county[1055] <- "Bamberg_SC"
    deidgroup$trumpvote[1055] <- 35.5
    deidgroup$county[1056] <- "Orangeburg_SC"
    deidgroup$trumpvote[1056] <- 30.7
    deidgroup$county[1057] <- "Knott_KY"
    deidgroup$trumpvote[1057] <- 75.6
    deidgroup$county[1058] <- "Pike_KY"
    deidgroup$trumpvote[1058] <- 80.1
    deidgroup$county[1059] <- "Chester_TN"
    deidgroup$trumpvote[1059] <- 78.9
    deidgroup$county[1060] <- "Pasco_FL"
    deidgroup$trumpvote[1060] <- 58.9
    deidgroup$county[1061] <- "Woodford_KY"
    deidgroup$trumpvote[1061] <- 56.8
    deidgroup$county[1062] <- "Adair_KY"
    deidgroup$trumpvote[1062] <- 80.6
    deidgroup$county[1063] <- "Benton_AR"
    deidgroup$trumpvote[1063] <- 62.9
    deidgroup$county[1064] <- "Laurens_SC"
    deidgroup$trumpvote[1064] <- 63.3
    deidgroup$county[1065] <- "Abbeville_SC"
    deidgroup$trumpvote[1065] <- 62.9
    deidgroup$county[1066] <- "Jefferson_TN"
    deidgroup$trumpvote[1066] <- 77.7
    deidgroup$county[1067] <- "Upshur_WV"
    deidgroup$trumpvote[1067] <- 75.9
    deidgroup$county[1068] <- "Hamilton_TN"
    deidgroup$trumpvote[1068] <- 55.8
    deidgroup$county[1069] <- "Madison_NC"
    deidgroup$trumpvote[1069] <- 61.4
    deidgroup$county[1070] <- "White_GA"
    deidgroup$trumpvote[1070] <- 82.8
    deidgroup$county[1071] <- "Lawrence_AR"
    deidgroup$trumpvote[1071] <- 71.5
    deidgroup$county[1072] <- "Harnett_NC"
    deidgroup$trumpvote[1072] <- 60.7
    deidgroup$county[1073] <- "Troup_GA"
    deidgroup$trumpvote[1073] <- 60.6
    deidgroup$county[1074] <- "Clark_AR"
    deidgroup$trumpvote[1074] <- 51.7
    deidgroup$county[1075] <- "Brooke_WV"
    deidgroup$trumpvote[1075] <- 68.9
    deidgroup$county[1076] <- "Stanly_NC"
    deidgroup$trumpvote[1076] <- 74
    deidgroup$county[1077] <- "Sumter_SC"
    deidgroup$trumpvote[1077] <- 42.5
    deidgroup$county[1078] <- "Carter_KY"
    deidgroup$trumpvote[1078] <- 73.8
    deidgroup$county[1079] <- "Towns_GA"
    deidgroup$trumpvote[1079] <- 79.9
    deidgroup$county[1080] <- "McMinn_TN"
    deidgroup$trumpvote[1080] <- 78.5
    deidgroup$county[1081] <- "Franklin_TN"
    deidgroup$trumpvote[1081] <- 70.4
    deidgroup$county[1082] <- "Taylor_KY"
    deidgroup$trumpvote[1082] <- 73.6
    deidgroup$county[1083] <- "Claiborne_TN"
    deidgroup$trumpvote[1083] <- 80.2
    deidgroup$county[1084] <- "Whitley_KY"
    deidgroup$trumpvote[1084] <- 82.2
    deidgroup$county[1085] <- "Giles_TN"
    deidgroup$trumpvote[1085] <- 71.6
    deidgroup$county[1086] <- "Johnson_AR"
    deidgroup$trumpvote[1086] <- 66.8
    deidgroup$county[1087] <- "Berrien_MI"
    deidgroup$trumpvote[1087] <- 53.8
    deidgroup$county[1088] <- "Greene_OH"
    deidgroup$trumpvote[1088] <- 59.7
    deidgroup$county[1089] <- "Hennepin_MN"
    deidgroup$trumpvote[1089] <- 28.5
    deidgroup$county[1090] <- "Taney_MO"
    deidgroup$trumpvote[1090] <- 78
    deidgroup$county[1091] <- " Walla Walla_WA"
    deidgroup$trumpvote[1091] <- 54.6
    deidgroup$county[1092] <- "McPherson_KS"
    deidgroup$trumpvote[1092] <- 67.6
    deidgroup$county[1093] <- "Gibson_IN"
    deidgroup$trumpvote[1093] <- 71.6
    deidgroup$county[1094] <- "Grant_IN"
    deidgroup$trumpvote[1094] <- 67.4
    deidgroup$county[1095] <- "Muskingum_OH"
    deidgroup$trumpvote[1095] <- 65.1
    deidgroup$county[1096] <- "Burleigh_ND"
    deidgroup$trumpvote[1096] <- 69.3
    deidgroup$county[1097] <- "Grant_ND"
    deidgroup$trumpvote[1097] <- 51.3
    deidgroup$county[1098] <- "McPherson_KS"
    deidgroup$trumpvote[1098] <- 67.6
    deidgroup$county[1099] <- "Jackson_MI"
    deidgroup$trumpvote[1099] <- 57.2
    deidgroup$county[1100] <- "Howard_MO"
    deidgroup$trumpvote[1100] <- 67.6
    
      deidgroup$county[1101] <- "Clinton_OH"
    deidgroup$trumpvote[1101] <- 74.4
    deidgroup$county[1102] <- "Lea_NM"
    deidgroup$trumpvote[1102] <- 70.5
    deidgroup$county[1103] <- "Henry_IA"
    deidgroup$trumpvote[1103] <- 62.1
    deidgroup$county[1104] <- "Yankton_SD"
    deidgroup$trumpvote[1104] <- 58.8
    deidgroup$county[1105] <- "Woodford_IL"
    deidgroup$trumpvote[1105] <- 68
    deidgroup$county[1106] <- "Eaton_MI"
    deidgroup$trumpvote[1106] <- 49.6
    deidgroup$county[1107] <- "Marion_MO"
    deidgroup$trumpvote[1107] <- 73
    deidgroup$county[1108] <- "York_NE"
    deidgroup$trumpvote[1108] <- 74.9
    deidgroup$county[1109] <- "Morgan_IL"
    deidgroup$trumpvote[1109] <- 62
    deidgroup$county[1110] <- "Marion_KS"
    deidgroup$trumpvote[1110] <- 71.9
    deidgroup$county[1111] <- "Greene_PA"
    deidgroup$trumpvote[1111] <- 69.5
    deidgroup$county[1112] <- "Cambria_PA"
    deidgroup$trumpvote[1112] <- 67.5
    deidgroup$county[1113] <- "Mantiowoc_WI"
    deidgroup$trumpvote[1113] <- 58.1
    deidgroup$county[1114] <- "Atchison_KS"
    deidgroup$trumpvote[1114] <- 62.2
    deidgroup$county[1115] <- "Wood_TX"
    deidgroup$trumpvote[1115] <- 84.1
    deidgroup$county[1116] <- "Kerr_TX"
    deidgroup$trumpvote[1116] <- 76.5
    deidgroup$county[1117] <- "Allegany_NY"
    deidgroup$trumpvote[1117] <- 68.4
    deidgroup$county[1118] <- "Brown_TX"
    deidgroup$trumpvote[1118] <- 86.1
    deidgroup$county[1119] <- "Winneshiek_IA"
    deidgroup$trumpvote[1119] <- 47.5
    deidgroup$county[1120] <- "Johnson_TX"
    deidgroup$trumpvote[1120] <- 77.5
    deidgroup$county[1121] <- "Frederick_MD"
    deidgroup$trumpvote[1121] <- 49.1
    deidgroup$county[1122] <- "Douglas_KS"
    deidgroup$trumpvote[1122] <- 29.7
    deidgroup$county[1123] <- "Ventura_CA"
    deidgroup$trumpvote[1123] <- 39.2
    deidgroup$county[1124] <- "Sioux_IA"
    deidgroup$trumpvote[1124] <- 82.1
    deidgroup$county[1125] <- "Allen_OH"
    deidgroup$trumpvote[1125] <- 66.9
    deidgroup$county[1126] <- "Davison_SD"
    deidgroup$trumpvote[1126] <- 64.9
    deidgroup$county[1127] <- "Saline_MO"
    deidgroup$trumpvote[1127] <- 64.7
    deidgroup$county[1128] <- "Bremer_IA"
    deidgroup$trumpvote[1128] <- 53.9
    deidgroup$county[1129] <- "Vigo_IN"
    deidgroup$trumpvote[1129] <- 55.4
    deidgroup$county[1130] <- "Hillsdale_MI"
    deidgroup$trumpvote[1130] <- 70.9
    deidgroup$county[1131] <- "Wabash_IN"
    deidgroup$trumpvote[1131] <- 73.2
    deidgroup$county[1132] <- "Hardin_OH"
    deidgroup$trumpvote[1132] <- 71.1
    deidgroup$county[1133] <- "Mercer_PA"
    deidgroup$trumpvote[1133] <- 60.6
    deidgroup$county[1134] <- "Houghton_MI"
    deidgroup$trumpvote[1134] <- 54.2
    deidgroup$county[1135] <- "Bond_IL"
      deidgroup$trumpvote[1135] <- 65.5
      deidgroup$county[1136] <- "Knox_OH"
      deidgroup$trumpvote[1136] <- 66.9
      deidgroup$county[1137] <- "Sioux_IA"
    deidgroup$trumpvote[1137] <- 82.1
    deidgroup$county[1138] <- "Polk_MO"
    deidgroup$trumpvote[1138] <- 76.1
    deidgroup$county[1139] <- "Napa_CA"
    deidgroup$trumpvote[1139] <- 29.6
    deidgroup$county[1140] <- "Kosciusko_IN"
    deidgroup$trumpvote[1140] <- 74.9
    deidgroup$county[1141] <- "Nicollet_MN"
    deidgroup$trumpvote[1141] <- 47.1
    deidgroup$county[1142] <- "Cambria_PA"
    deidgroup$trumpvote[1142] <- 67.5
    deidgroup$county[1143] <- "Franklin_KS"
    deidgroup$trumpvote[1143] <- 65.9
    deidgroup$county[1144] <- "SanDiego_CA"
    deidgroup$trumpvote[1144] <- 38.7
    deidgroup$county[1145] <- "Lewis_MO"
    deidgroup$trumpvote[1145] <- 75.1
    deidgroup$county[1146] <- "Hale_TX"
    deidgroup$trumpvote[1146] <- 72.1
    deidgroup$county[1147] <- "Greene_OH"
    deidgroup$trumpvote[1147] <- 59.7
    deidgroup$county[1148] <- "Stearns_MN"
    deidgroup$trumpvote[1148] <- 60.3
    deidgroup$county[1149] <- "RapidesParish_LA"
    deidgroup$trumpvote[1149] <- 64.8
    deidgroup$county[1150] <- "Richland_SC"
    deidgroup$trumpvote[1150] <- 31.1
    deidgroup$county[1151] <- "Gaston_NC"
    deidgroup$trumpvote[1151] <- 64.8
    deidgroup$county[1152] <- "Charleston_SC"
    deidgroup$trumpvote[1152] <- 42.8
    deidgroup$county[1153] <- "Davidson_TN"
    deidgroup$trumpvote[1153] <- 34.3
    deidgroup$county[1154] <- "Wake_NC"
    deidgroup$trumpvote[1154] <- 37.9
    deidgroup$county[1155] <- "Montgomery_AL"
    deidgroup$trumpvote[1155] <- 35.9
    deidgroup$county[1156] <- "Carter_TN"
    deidgroup$trumpvote[1156] <- 80.5
    deidgroup$county[1157] <- "Jessamine_KY"
    deidgroup$trumpvote[1157] <- 66.4
    deidgroup$county[1158] <- "VirginiaBeachCity_VA"
    deidgroup$trumpvote[1158] <- 49.1
    deidgroup$county[1159] <- "OrleansParish_LA"
    deidgroup$trumpvote[1159] <- 14.7
    deidgroup$county[1160] <- "St.JohnTheBaptistParish_LA"
    deidgroup$trumpvote[1160] <- 36.5
    deidgroup$county[1161] <- "Buncombe_NC"
    deidgroup$trumpvote[1161] <- 41.1
    deidgroup$county[1162] <- "CaddoParish_LA"
    deidgroup$trumpvote[1162] <- 46.3
    deidgroup$county[1163] <- "Bibb_GA"
    deidgroup$trumpvote[1163] <- 38.7
    deidgroup$county[1164] <- "Troup_GA"
      deidgroup$trumpvote[1164] <- 60.6
      deidgroup$county[1165] <- "Rockingham_VA"
    deidgroup$trumpvote[1165] <- 69.2
    deidgroup$county[1166] <- "Sumner_TN"
    deidgroup$trumpvote[1166] <- 70.5
    deidgroup$county[1167] <- "Hanover_VA"
    deidgroup$trumpvote[1167] <- 63.5
    deidgroup$county[1168] <- "Greenville_SC"
    deidgroup$trumpvote[1168] <- 59.4
    deidgroup$county[1169] <- "Nash_NC"
    deidgroup$trumpvote[1169] <- 49.3
    deidgroup$county[1170] <- "Carroll_TN"
      deidgroup$trumpvote[1170] <- 74.8
      deidgroup$county[1171] <- "Arlington_VA"
    deidgroup$trumpvote[1171] <- 16.9
    deidgroup$county[1172] <- "Mobile_AL"
    deidgroup$trumpvote[1172] <- 55.7
    deidgroup$county[1173] <- "Dade_GA"
    deidgroup$trumpvote[1173] <- 80.9
    deidgroup$county[1174] <- "White_AR"
    deidgroup$trumpvote[1174] <- 75.3
    deidgroup$county[1175] <- "Miami-Dade_FL"
    deidgroup$trumpvote[1175] <- 34.1
    deidgroup$county[1176] <- "Rowan_NC"
    deidgroup$trumpvote[1176] <- 67.2
    deidgroup$county[1177] <- "Guilford_NC"
    deidgroup$trumpvote[1177] <- 38.7
    deidgroup$county[1178] <- "Hinds_MS"
    deidgroup$trumpvote[1178] <- 26.9
    deidgroup$county[1179] <- "VirginiaBeachCity_VA"
    deidgroup$trumpvote[1179] <- 49.1
    deidgroup$county[1180] <- "Floyd_GA"
    deidgroup$trumpvote[1180] <- 70.2
    deidgroup$county[1181] <- "Jefferson_AL"
    deidgroup$trumpvote[1181] <- 45
    deidgroup$county[1182] <- "Montgomery_AL"
    deidgroup$trumpvote[1182] <- 35.9
    deidgroup$county[1183] <- "Floyd_GA"
    deidgroup$trumpvote[1183] <- 70.2
    deidgroup$county[1184] <- "Ellis_TX"
    deidgroup$trumpvote[1184] <- 71.1
    deidgroup$county[1185] <- "Bristol_MA"
    deidgroup$trumpvote[1185] <- 42.6
    deidgroup$county[1186] <- "Kane_IL"
    deidgroup$trumpvote[1186] <- 42.4
    deidgroup$county[1187] <- "Lucas_OH"
    deidgroup$trumpvote[1187] <- 38.7
    deidgroup$county[1188] <- "Philadelphia_PA"
    deidgroup$trumpvote[1188] <- 15.5
    deidgroup$county[1189] <- "Erie_PA"
    deidgroup$trumpvote[1189] <- 48.8
    deidgroup$county[1190] <- "Stark_OH"
    deidgroup$trumpvote[1190] <- 56.4
    deidgroup$county[1191] <- "Morris_NJ"
    deidgroup$trumpvote[1191] <- 50.4
    deidgroup$county[1192] <- "Kaufman_TX"
    deidgroup$trumpvote[1192] <- 72.1
    deidgroup$county[1193] <- "Kankakee_IL"
      deidgroup$trumpvote[1193] <- 53.9
      deidgroup$county[1194] <- "SanDiego_CA"
    deidgroup$trumpvote[1194] <- 38.7
    deidgroup$county[1195] <- "Washington_OK"
    deidgroup$trumpvote[1195] <-71.2
    deidgroup$county[1196] <- "Bergen_NJ"
    deidgroup$trumpvote[1196] <- 42.5
    deidgroup$county[1197] <- "Dupage_IL"
    deidgroup$trumpvote[1197] <- 39.8
    deidgroup$county[1198] <- "Lancaster_NE"
    deidgroup$trumpvote[1198] <- 46.6
    deidgroup$county[1199] <- "Pierce_WA"
    deidgroup$trumpvote[1199] <- 42.3
    deidgroup$county[1200] <- "Yamhill_OR"
    deidgroup$trumpvote[1200] <- 50.1
    deidgroup$county[1201] <- "Chester_PA"
    deidgroup$trumpvote[1201] <- 43.3
    deidgroup$county[1202] <- "Taylor_TX"
    deidgroup$trumpvote[1202] <- 73.3
    deidgroup$county[1203] <- "Cuyahoga_OH"
    deidgroup$trumpvote[1203] <- 30.8
    deidgroup$county[1204] <- "Montgomery_PA"
    deidgroup$trumpvote[1204] <- 37.6
    deidgroup$county[1205] <- "Spokane_WA"
    deidgroup$trumpvote[1205] <- 49.8
    deidgroup$county[1206] <- "Milwaukee_WI"
    deidgroup$trumpvote[1206] <- 29
    deidgroup$county[1207] <- "Denver_CO"
    deidgroup$trumpvote[1207] <- 18.8
    deidgroup$county[1208] <- "LosAngeles_CA"
    deidgroup$trumpvote[1208] <- 23.4
    deidgroup$county[1209] <- "Adams_NE"
    deidgroup$trumpvote[1209] <- 69.9
    deidgroup$county[1210] <- "Ozaukee_WI"
    deidgroup$trumpvote[1210] <- 57.1
    deidgroup$county[1211] <- "Bucks_PA"
    deidgroup$trumpvote[1211] <- 47.8
    deidgroup$county[1212] <- "Orange_CA"
    deidgroup$trumpvote[1212] <- 44.8
    deidgroup$county[1213] <- "Essex_NJ"
    deidgroup$trumpvote[1213] <- 20.7
    deidgroup$county[1214] <- "Kent_MI"
    deidgroup$trumpvote[1214] <- 48.3
    deidgroup$county[1215] <- "LosAngeles_CA"
    deidgroup$trumpvote[1215] <- 23.4
    deidgroup$county[1216] <- "Okmulgee_OK"
    deidgroup$trumpvote[1216] <- 64.1
    deidgroup$county[1217] <- "St.Louis_MO"
    deidgroup$trumpvote[1217] <- 39.5
    deidgroup$county[1218] <- "Seward_NE"
    deidgroup$trumpvote[1218] <- 70.3
    deidgroup$county[1219] <- "Chittenden_VT"
    deidgroup$trumpvote[1219] <- 23.7
    deidgroup$county[1220] <- "Marion_IN"
    deidgroup$trumpvote[1220] <- 36.2
    deidgroup$county[1221] <- "Multnomah_OR"
      deidgroup$trumpvote[1221] <- 17.6
      deidgroup$county[1222] <- "Monroe_NY"
    deidgroup$trumpvote[1222] <- 40.3
    deidgroup$county[1223] <- "Bucks_PA"
    deidgroup$trumpvote[1223] <- 47.8
    deidgroup$county[1224] <- "Oklahoma_OK"
    deidgroup$trumpvote[1224] <- 51.7
    deidgroup$county[1225] <- "Cuyahoga_OH"
    deidgroup$trumpvote[1225] <-30.8
    deidgroup$county[1226] <- "Hamilton_OH"
    deidgroup$trumpvote[1226] <- 43
    deidgroup$county[1227] <- "Dodge_NE"
    deidgroup$trumpvote[1227] <- 65.1
    deidgroup$county[1228] <- "Montgomery_OH"
    deidgroup$trumpvote[1228] <- 48.4
    deidgroup$county[1229] <- "Oklahoma_OK"
      deidgroup$trumpvote[1229] <- 51.7
      deidgroup$county[1230] <- "Travis_TX"
    deidgroup$trumpvote[1230] <- 27.4
    deidgroup$county[1231] <- "Hillsborough_NH"
    deidgroup$trumpvote[1231] <- 47.5
    deidgroup$county[1232] <- "Cuyahoga_OH"
    deidgroup$trumpvote[1232] <- 30.8
    deidgroup$county[1233] <- "Delaware_PA"
    deidgroup$trumpvote[1233] <- 37.4
    deidgroup$county[1234] <- "Dallas_TX"
    deidgroup$trumpvote[1234] <- 34.9
    deidgroup$county[1235] <- "Stearns_MN"
    deidgroup$trumpvote[1235] <-60.3
    deidgroup$county[1236] <- "Huntington_IN"
    deidgroup$trumpvote[1236] <- 72.9
    deidgroup$county[1237] <- "Rockland_NY"
    deidgroup$trumpvote[1237] <- 46.1
    deidgroup$county[1238] <- "Orange_CA"
    deidgroup$trumpvote[1238] <- 44.8
    deidgroup$county[1239] <- "Chester_PA"
    deidgroup$trumpvote[1239] <- 43.3
    deidgroup$county[1240] <- "Delaware_PA"
    deidgroup$trumpvote[1240] <- 37.4
    deidgroup$county[1241] <- "Lamar_GA"
    deidgroup$trumpvote[1241] <- 68.4
    deidgroup$county[1242] <- "Marin_CA"
    deidgroup$trumpvote[1242] <- 16.1
    deidgroup$county[1243] <- "Worcester_MA"
    deidgroup$trumpvote[1243] <- 41.2
    deidgroup$county[1244] <- "Worcester_MA"
    deidgroup$trumpvote[1244] <- 41.2
    deidgroup$county[1245] <- "Berks_PA"
    deidgroup$trumpvote[1245] <- 52.9
    deidgroup$county[1246] <- "Johnson_KS"
      deidgroup$trumpvote[1246] <- 47.9
      deidgroup$county[1247] <- "Milwaukee_WI"
    deidgroup$trumpvote[1247] <- 29
    deidgroup$county[1248] <- "Clay_MN"
    deidgroup$trumpvote[1248] <- 46.5
    deidgroup$county[1249] <- "St.Louis_MO"
    deidgroup$trumpvote[1249] <- 39.5
    deidgroup$county[1250] <- "Luzerene_PA"
    deidgroup$trumpvote[1250] <- 58.4
    deidgroup$county[1251] <- "Albany_NY"
    deidgroup$trumpvote[1251] <- 35.2
    deidgroup$county[1252] <- "Oakland_MI"
    deidgroup$trumpvote[1252] <- 43.6
    deidgroup$county[1253] <- "Montogomery_PA"
    deidgroup$trumpvote[1253] <- 37.6
    deidgroup$county[1254] <- "LosAngeles_CA"
    deidgroup$trumpvote[1254] <- 23.4
    deidgroup$county[1255] <- "Orange_CA"
    deidgroup$trumpvote[1255] <- 44.8
    deidgroup$county[1256] <- "Tarrant_TX"
    deidgroup$trumpvote[1256] <- 52.2
    deidgroup$county[1257] <- "Wayne_MI"
    deidgroup$trumpvote[1257] <- 29.4
    deidgroup$county[1258] <- "Delaware_PA"
    deidgroup$trumpvote[1258] <- 37.4
    deidgroup$county[1259] <- "Cuyahoga_OH"
    deidgroup$trumpvote[1259] <- 30.8
    deidgroup$county[1260] <- "Anderson_SC"
    deidgroup$trumpvote[1260] <- 69.9
    deidgroup$county[1261] <- "King_WA"
    deidgroup$trumpvote[1261] <- 21.4
    deidgroup$county[1262] <- "Lenawee_MI"
    deidgroup$trumpvote[1262] <- 57.6
    deidgroup$county[1263] <- "Essex_NJ"
    deidgroup$trumpvote[1263] <- 20.7
    deidgroup$county[1264] <- "Shasta_CA"
    deidgroup$trumpvote[1264] <- 65.6
    deidgroup$county[1265] <- "Lackawanna_PA"
    deidgroup$trumpvote[1265] <- 46.8
    deidgroup$county[1266] <- "Brown_WI"
    deidgroup$trumpvote[1266] <- 52.7
    deidgroup$county[1267] <- "Bell_TX"
    deidgroup$trumpvote[1267] <- 55.1
    deidgroup$county[1268] <- "Waukesha_WI"
    deidgroup$trumpvote[1268] <- 61.6
    deidgroup$county[1269] <- "Norfolk_MA"
    deidgroup$trumpvote[1269] <- 33.3
    deidgroup$county[1270] <- "Thurston_WA"
    deidgroup$trumpvote[1270] <- 38.0
    deidgroup$county[1271] <- "Fairfield_CT"
    deidgroup$trumpvote[1271] <- 39.4
    deidgroup$county[1272] <- "Hillsborough_NH"
    deidgroup$trumpvote[1272] <- 47.5
    deidgroup$county[1273] <- "Dallas_TX"
    deidgroup$trumpvote[1273] <- 34.9
    deidgroup$county[1274] <- "Montgomery_MD" 
    deidgroup$trumpvote[1274] <- 20.3
    deidgroup$county[1275] <- "Onondaga_NY"
    deidgroup$trumpvote[1275] <- 40.8
    deidgroup$county[1276] <- "Philadephia_PA"
    deidgroup$trumpvote[1276] <- 15.5
    deidgroup$county[1277] <- "SanMateo_CA"
    deidgroup$trumpvote[1277] <- 19.1
    deidgroup$county[1278] <- "Harvey_KS"
    deidgroup$trumpvote[1278] <- 58.5
    deidgroup$county[1279] <- "Lehigh_PA"
    deidgroup$trumpvote[1279] <- 45.9
    deidgroup$county[1280] <- "ContraCosta_CA"
    deidgroup$trumpvote[1280] <- 26.1
    deidgroup$county[1281] <- "Worcester_MA"
    deidgroup$trumpvote[1281] <- 41.2
    deidgroup$county[1282] <- "Linn_IA"
    deidgroup$trumpvote[1282] <- 42
    deidgroup$county[1283] <- "St.Louis_MN"
    deidgroup$trumpvote[1283] <- 40.1
    deidgroup$county[1284] <- "Westchester_NY"
    deidgroup$trumpvote[1284] <- 32.1
    deidgroup$county[1285] <- "Worcester_MA"
    deidgroup$trumpvote[1285] <- 41.2
    deidgroup$county[1286] <- "Ocean_NJ"
    deidgroup$trumpvote[1286] <- 65.5
    deidgroup$county[1287] <- "Rockland_NY"
    deidgroup$trumpvote[1287] <- 46.1
    deidgroup$county[1288] <- "LosAngeles_CA"
    deidgroup$trumpvote[1288] <- 23.4
    deidgroup$county[1289] <- "Harrison_TX"
    deidgroup$trumpvote[1289] <- 71
    deidgroup$county[1290] <- "Marion_OR"
    deidgroup$trumpvote[1290] <- 49
    deidgroup$county[1291] <- "Ramsey_MN"
    deidgroup$trumpvote[1291] <- 26.3
    deidgroup$county[1292] <- "Cook_IL"
    deidgroup$trumpvote[1292] <- 21.4
    deidgroup$county[1293] <- "LosAngeles_CA"
    deidgroup$trumpvote[1293] <- 23.4
    deidgroup$county[1294] <- "Placer_CA"
    deidgroup$trumpvote[1294] <- 52.5
    deidgroup$county[1295] <- "Westchester_NY"
    deidgroup$trumpvote[1295] <- 32.1
    deidgroup$county[1296] <- "Cook_IL"
    deidgroup$trumpvote[1296] <- 21.4
    deidgroup$county[1297] <- "Will_IL"
    deidgroup$trumpvote[1297] <- 44.6
    deidgroup$county[1298] <- "Dupage_IL"
    deidgroup$trumpvote[1298] <- 39.8
    deidgroup$county[1299] <- "Middlesex_MA"
    deidgroup$trumpvote[1299] <- 28.2
    
    deidgroup$county[1300] <- "Stark_OH"
    deidgroup$trumpvote[1300] <- 56.4
    deidgroup$county[1301] <- "Niagara_NY"
    deidgroup$trumpvote[1301] <- 57.2
    deidgroup$county[1302] <- "Dupage_IL"
    deidgroup$trumpvote[1302] <- 39.8
    deidgroup$county[1303] <- "Essex_MA"
    deidgroup$trumpvote[1303] <- 36
    deidgroup$county[1304] <- "Kent_MI"
    deidgroup$trumpvote[1304] <- 48.3
    deidgroup$county[1305] <- "Allen_IN"
    deidgroup$trumpvote[1305] <- 57.5
    deidgroup$county[1306] <- "Allegheny_PA"
    deidgroup$trumpvote[1306] <- 40
    deidgroup$county[1307] <- "Riverside_CA"
    deidgroup$trumpvote[1307] <- 46.7
    deidgroup$county[1308] <- "Beaver_PA"
    deidgroup$trumpvote[1308] <- 58.3
    deidgroup$county[1309] <- "Ventura_CA"
    deidgroup$trumpvote[1309] <- 39.2
    deidgroup$county[1310] <- "Cumberland_PA"
    deidgroup$trumpvote[1310] <- 57.1
    deidgroup$county[1311] <- "Ramsey_MN"
    deidgroup$trumpvote[1311] <- 26.3
    deidgroup$county[1312] <- "Monroe_NY"
    deidgroup$trumpvote[1312] <- 40.3
    deidgroup$county[1313] <- "Philadelphia_PA"
    deidgroup$trumpvote[1313] <- 15.5
    deidgroup$county[1314] <- "Cook_IL"
      deidgroup$trumpvote[1314] <- 21.4
      deidgroup$county[1315] <- "St.Joseph_IN"
    deidgroup$trumpvote[1315] <- 47.5
    deidgroup$county[1316] <- "Orange_CA"
    deidgroup$trumpvote[1316] <- 44.8
    deidgroup$county[1317] <- "Leavenworth_KS"
    deidgroup$trumpvote[1317] <- 58.6
    deidgroup$county[1318] <- "Middlesex_MA"
    deidgroup$trumpvote[1318] <- 28.2
    deidgroup$county[1319] <- "Kent_MI"
    deidgroup$trumpvote[1319] <- 48.3
    deidgroup$county[1320] <- "Hinds_MS"
    deidgroup$trumpvote[1320] <- 26.9
    deidgroup$county[1321] <- "PalmBeach_FL"
    deidgroup$trumpvote[1321] <- 41.4
    deidgroup$county[1322] <- "Hillsborough_FL"
      deidgroup$trumpvote[1322] <- 44.7
      deidgroup$county[1323] <- "Ohio_WV"
    deidgroup$trumpvote[1323] <- 62.2
    deidgroup$county[1324] <- "Madison_TN"
    deidgroup$trumpvote[1324] <- 56.5
    deidgroup$county[1325] <- "Forrest_MS"
    deidgroup$trumpvote[1325] <- 55.5
    deidgroup$county[1326] <- "Bibb_GA" 
    deidgroup$trumpvote[1326] <- 38.7
    deidgroup$county[1327] <- "Madison_TN"
    deidgroup$trumpvote[1327] <- 56.5
    deidgroup$county[1328] <- "Sullivan_TN"
    deidgroup$trumpvote[1328] <- 76.1
    deidgroup$county[1329] <- "Daviess_KY"
    deidgroup$trumpvote[1329] <- 63.1
    deidgroup$county[1330] <- "LynchburgCity_VA"
    deidgroup$trumpvote[1330] <- 50.9
    deidgroup$county[1331] <- "Newberry_SC"
    deidgroup$trumpvote[1331] <- 59.6
    deidgroup$county[1332] <- "Bradley_TN"
    deidgroup$trumpvote[1332] <- 77.5
    deidgroup$county[1333] <- "Wood_WV"
    deidgroup$trumpvote[1333] <- 71.4
    deidgroup$county[1334] <- "Cumberland_NC"
    deidgroup$trumpvote[1334] <- 40.7
    deidgroup$county[1335] <- "Anderson_SC"
    deidgroup$trumpvote[1335] <- 69.9
    deidgroup$county[1336] <- "Madison_AL"
    deidgroup$trumpvote[1336] <- 55.9
    deidgroup$county[1337] <- "Catawba_NC"
    deidgroup$trumpvote[1337] <- 67.6
    deidgroup$county[1338] <- "Miami-Dade_FL"
    deidgroup$trumpvote[1338] <- 34.1
    deidgroup$county[1339] <- "Harvey_KS"
    deidgroup$trumpvote[1339] <- 58.5
    deidgroup$county[1340] <- "Dubuque_IA"
    deidgroup$trumpvote[1340] <- 47.7
    deidgroup$county[1341] <- "Saline_KS"
    deidgroup$trumpvote[1341] <- 63
    deidgroup$county[1342] <- "Providence_RI"
    deidgroup$trumpvote[1342] <- 37.6
    deidgroup$county[1343] <- "Pottawatomie_OK"
    deidgroup$trumpvote[1343] <- 70.1
    deidgroup$county[1344] <- "Mclennan_TX"
    deidgroup$trumpvote[1344] <- 61.7
    deidgroup$county[1345] <- "Grant_IN"
    deidgroup$trumpvote[1345] <- 67.4
    deidgroup$county[1346] <- "Lackawanna_PA"
    deidgroup$trumpvote[1346] <- 46.8
    deidgroup$county[1347] <- "Genesee_MI"
    deidgroup$trumpvote[1347] <- 42.9
    deidgroup$county[1348] <- "St.Joseph_IN"
    deidgroup$trumpvote[1348] <- 47.5
    deidgroup$county[1349] <- "Dane_WI"
    deidgroup$trumpvote[1349] <- 23.4
    deidgroup$county[1350] <- "Taylor_TX"
    deidgroup$trumpvote[1350] <- 73.3
    deidgroup$county[1351] <- "Spokane_WA"
    deidgroup$trumpvote[1351] <- 49.9
    deidgroup$county[1352] <- "Luzerne_PA"
    deidgroup$trumpvote[1352] <- 58.4
    deidgroup$county[1353] <- "Erie_PA"
    deidgroup$trumpvote[1353] <- 48.8
    deidgroup$county[1354] <- "Utah_UT"
    deidgroup$trumpvote[1354] <- 51.5
    deidgroup$county[1355] <- "Minnehaha_SD"
    deidgroup$trumpvote[1355] <- 53.7
    deidgroup$county[1356] <- "Adams_IL"
    deidgroup$trumpvote[1356] <- 71.6
    deidgroup$county[1357] <- "Fond du Lac_WI"
    deidgroup$trumpvote[1357] <- 60.8
    deidgroup$county[1358] <- "Stark_OH"
    deidgroup$trumpvote[1358] <- 56.4
    deidgroup$county[1359] <- "Gregg_TX"
    deidgroup$trumpvote[1359] <- 69.4
    deidgroup$county[1360] <- "Canyon_ID"
    deidgroup$trumpvote[1360] <- 65
    deidgroup$county[1361] <- "McPherson_KS"
    deidgroup$trumpvote[1361] <- 67.6
    deidgroup$county[1362] <- "Ottawa_MI"
    deidgroup$trumpvote[1362] <- 62.2
    deidgroup$county[1363] <- "Porter_IN"
    deidgroup$trumpvote[1363] <- 50.6
    deidgroup$county[1364] <- "Scott_IA"
    deidgroup$trumpvote[1364] <- 46
    deidgroup$county[1365] <- "Oklahoma_OK"
    deidgroup$trumpvote[1365] <- 51.7
    deidgroup$county[1366] <- "Kent_MI"
    deidgroup$trumpvote[1366] <- 48.3
    deidgroup$county[1367] <- "Lane_OR"
    deidgroup$trumpvote[1367] <- 36.6
    deidgroup$county[1368] <- "Hampden_MA"
    deidgroup$trumpvote[1368] <- 39.1
    deidgroup$county[1369] <- "San_Diego_CA"
    deidgroup$trumpvote[1369] <- 38.2
    deidgroup$county[1370] <- "San_Diego_CA"
    deidgroup$trumpvote[1370] <- 38.2
    deidgroup$county[1371] <- "Taylor_TX"
    deidgroup$trumpvote[1371] <- 73.3
    deidgroup$county[1372] <- "Wayne_IN"
    deidgroup$trumpvote[1372] <- 62.7
    deidgroup$county[1373] <- "Allen_IN"
    deidgroup$trumpvote[1373] <- 57.5
    deidgroup$county[1374] <- "Clark_OH"
    deidgroup$trumpvote[1374] <- 57.5
    deidgroup$county[1375] <- "Honolulu_HI"
    deidgroup$trumpvote[1375] <- 31.7
    deidgroup$county[1376] <- "Blue Earth_MN"
    deidgroup$trumpvote[1376] <- 47.1
    deidgroup$county[1377] <- "Northampton_PA"
    deidgroup$trumpvote[1377] <- 50
    deidgroup$county[1378] <- "Woodbury_IA"
    deidgroup$trumpvote[1378] <- 57.4
    deidgroup$county[1379] <- "Minnehaha_SD"
    deidgroup$trumpvote[1379] <- 53.7
    deidgroup$county[1380] <- "Guadalupe_TX"
    deidgroup$trumpvote[1380] <- 63.8
    deidgroup$county[1381] <- "HarrisonCounty_TX"
    deidgroup$trumpvote[1381] <- 42
    deidgroup$county[1382] <- "Cook_IL"
    deidgroup$trumpvote[1382] <- 21.4
    deidgroup$county[1383] <- "Lubbock_TX"
    deidgroup$trumpvote[1383] <- 66.9
    deidgroup$county[1384] <- "Rock Island_IL"
    deidgroup$trumpvote[1384] <- 42.8
    deidgroup$county[1385] <- "Greene_MO"
    deidgroup$trumpvote[1385] <- 60.6
    deidgroup$county[1386] <- "Greene_MO"
    deidgroup$trumpvote[1386] <- 60.6
    deidgroup$county[1387] <- "Santa Clara_CA"
    deidgroup$trumpvote[1387] <- 20.9
    deidgroup$county[1388] <- "Lancaster_NE"
    deidgroup$trumpvote[1388] <- 46.6
    deidgroup$county[1389] <- "Elkhart_IN"
    deidgroup$trumpvote[1389] <- 64.1
    deidgroup$county[1390] <- "Seneca_OH"
    deidgroup$trumpvote[1390] <- 62
    deidgroup$county[1391] <- "BexarCounty_TX"
    deidgroup$trumpvote[1391] <- 41
    deidgroup$county[1392] <- "Guilford_NC"
    deidgroup$trumpvote[1392] <- 38.7
    deidgroup$county[1393] <- "OrleansParish_LA"
    deidgroup$trumpvote[1393] <- 14.7
    deidgroup$county[1394] <- "Shelby_TN"
    deidgroup$trumpvote[1394] <- 34.6
    deidgroup$county[1395] <- "Davidson_TN"
    deidgroup$trumpvote[1395] <- 34.3
    deidgroup$county[1396] <- "Daviess_KY"
    deidgroup$trumpvote[1396] <- 63.1
    deidgroup$county[1397] <- "Guilford_NC"
    deidgroup$trumpvote[1397] <- 38.7
    deidgroup$county[1398] <- "Richmond City_VA"
    deidgroup$trumpvote[1398] <- 15
    deidgroup$county[1399] <- "Pulaski_AR"
    deidgroup$trumpvote[1399] <- 38.4
    
    deidgroup$county[1400] <- "Wake_NC"
    deidgroup$trumpvote[1400] <- 37.9
    deidgroup$county[1401] <- "Jefferson_AL"
    deidgroup$trumpvote[1401] <- 45
    deidgroup$county[1402] <- "Wake_NC"
    deidgroup$trumpvote[1402] <- 37.9
    deidgroup$county[1403] <- "Pulaski_AR"
    deidgroup$trumpvote[1403] <- 38.4
    deidgroup$county[1404] <- "Davidson_TN"
    deidgroup$trumpvote[1404] <- 34.3
    deidgroup$county[1405] <- "Faulkner_AR"
    deidgroup$trumpvote[1405] <- 61.8
    deidgroup$county[1406] <- "FresnoCounty_CA"
    deidgroup$trumpvote[1406] <- 45.5
    deidgroup$county[1407] <- "Travis_TX" 
    deidgroup$trumpvote[1407] <- 27.4
    deidgroup$county[1408] <- "Suffolk_MA"
    deidgroup$trumpvote[1408] <- 16.5
    deidgroup$county[1409] <- "Wyandotte_KS"
    deidgroup$trumpvote[1409] <- 32.7
    deidgroup$county[1410] <- "Los Angeles_CA"
    deidgroup$trumpvote[1410] <- 23.4
    deidgroup$county[1411] <- "Dubuque_IA"
    deidgroup$trumpvote[1411] <- 47.7
    deidgroup$county[1412] <- "Sedgwick_KS"
    deidgroup$trumpvote[1412] <- 56.1
    deidgroup$county[1413] <- "BronxCounty_NY"
    deidgroup$trumpvote[1413] <- 9.6
    deidgroup$county[1414] <- "Polk_IA"
    deidgroup$trumpvote[1414] <- 40.9
    deidgroup$county[1415] <- "PhiladelphiaCounty_PA"
    deidgroup$trumpvote[1415] <- 15.5
    deidgroup$county[1416] <- "BexarCounty_TX"
    deidgroup$trumpvote[1416] <- 31
    deidgroup$county[1417] <- "Cook_IL"
    deidgroup$trumpvote[1417] <- 21.4
    deidgroup$county[1418] <- "MilwaukeeCounty_WI"
    deidgroup$trumpvote[1418] <- 29
    deidgroup$county[1419] <- "Erie_NY"
    deidgroup$trumpvote[1419] <- 45.4
    deidgroup$county[1420] <- "Los Angeles_CA" 
    deidgroup$trumpvote[1420] <- 23.4
    deidgroup$county[1421] <- "Multnomah_OR"
    deidgroup$trumpvote[1421] <- 17.6
    deidgroup$county[1422] <- "Hudson_NJ"
    deidgroup$trumpvote[1422] <- 22.6
    deidgroup$county[1423] <- "St. Louis_MO"
    deidgroup$trumpvote[1423] <- 39.5
    deidgroup$county[1424] <- "Franklin_OH"
    deidgroup$trumpvote[1424] <- 34.7
    deidgroup$county[1425] <- "BronxCounty_NY"
    deidgroup$trumpvote[1425] <- 9.6
    deidgroup$county[1426] <- "Washington_DC"
    deidgroup$trumpvote[1426] <- 4.1
    deidgroup$county[1427] <- "Ramsey_MN"
    deidgroup$trumpvote[1427] <- 26.3
    deidgroup$county[1428] <- "New York_NY"
    deidgroup$trumpvote[1428] <- 10
    deidgroup$county[1429] <- "MilwaukeeCounty_WI"
    deidgroup$trumpvote[1429] <- 29
    deidgroup$county[1430] <- "Jackson_MO"
    deidgroup$trumpvote[1430] <- 39
    deidgroup$county[1431] <- "New York_NY"
    deidgroup$trumpvote[1431] <- 10
    deidgroup$county[1432] <- "Ramsey_MN"
    deidgroup$trumpvote[1432] <- 26.3
    deidgroup$county[1433] <- "Oklahoma_OK"
    deidgroup$trumpvote[1433] <- 51.7
    deidgroup$county[1434] <- "San_Diego_CA"
    deidgroup$trumpvote[1434] <- 38.2
    deidgroup$county[1435] <- "Ramsey_MN"
    deidgroup$trumpvote[1435] <- 26.3
    deidgroup$county[1436] <- "QueensCounty_NY"
    deidgroup$trumpvote[1436] <- 22
    deidgroup$county[1437] <- "San_Francisco_CA"
    deidgroup$trumpvote[1437] <- 9.4
    deidgroup$county[1438] <- "Harris_TX"
    deidgroup$trumpvote[1438] <- 41.8
    deidgroup$county[1439] <- "TravisCounty_TX"
    deidgroup$trumpvote[1439] <- 27.4
    deidgroup$county[1440] <- "Lewis and Clark_MT"
    deidgroup$trumpvote[1440] <- 49.3
    deidgroup$county[1441] <- "Hamilton_OH"
    deidgroup$trumpvote[1441] <- 43
    deidgroup$county[1442] <- "Lawrence_PA"
    deidgroup$trumpvote[1442] <- 62.4
    deidgroup$county[1443] <- "Hennepin_MN"
    deidgroup$trumpvote[1443] <- 28.5
    deidgroup$county[1444] <- "Washington_DC"
    deidgroup$trumpvote[1444] <- 4.1
    deidgroup$county[1445] <- "Allegheny_PA"
    deidgroup$trumpvote[1445] <- 40
    deidgroup$county[1446] <- "Allegheny_PA"
    deidgroup$trumpvote[1446] <- 40
    deidgroup$county[1447] <- "BronxCounty_NY"
    deidgroup$trumpvote[1447] <- 9.6
    deidgroup$county[1448] <- "Douglas_NE"
    deidgroup$trumpvote[1448] <- 46.5
    deidgroup$county[1449] <- "Douglas_NE" 
    deidgroup$trumpvote[1449] <- 46.5
    deidgroup$county[1450] <- "Maricopa_AZ"
    deidgroup$trumpvote[1450] <- 49.1
    
    deidgroup$county[1451] <- "Hennepin_MN"
    deidgroup$trumpvote[1451] <- 28.5
    deidgroup$county[1452] <- "Multnomah_OR"
    deidgroup$trumpvote[1452] <- 17.6
    deidgroup$county[1453] <- "New York_NY"
    deidgroup$trumpvote[1453] <- 10
    deidgroup$county[1454] <- "Baltimore City_MD"
    deidgroup$trumpvote[1454] <- 10.9
    deidgroup$county[1455] <- "New York_NY"
    deidgroup$trumpvote[1455] <- 10
    deidgroup$county[1456] <- "Tarrant_TX"
    deidgroup$trumpvote[1456] <- 52.2
    deidgroup$county[1457] <- "Alameda_CA"
    deidgroup$trumpvote[1457] <- 14.9
    deidgroup$county[1458] <- "Wayne_MI"
    deidgroup$trumpvote[1458] <- 29.5
    deidgroup$county[1459] <- "Franklin_OH"
    deidgroup$trumpvote[1459] <- 34.7
    deidgroup$county[1460] <- "BexarCounty_TX"
    deidgroup$trumpvote[1460] <- 41
    deidgroup$county[1461] <- "Dallas_TX"
    deidgroup$trumpvote[1461] <- 34.9
    deidgroup$county[1462] <- "Ramsey_MN"
    deidgroup$trumpvote[1462] <- 26.3
    deidgroup$county[1463] <- "San_Diego_CA"
    deidgroup$trumpvote[1463] <- 38.2
    deidgroup$county[1464] <- "Sedgwick_KS"
    deidgroup$trumpvote[1464] <- 56.1
    deidgroup$county[1465] <- "King_WA"
    deidgroup$trumpvote[1465] <- 21.7
    deidgroup$county[1466] <- "Hartford_CT"
    deidgroup$trumpvote[1466] <- 37.1
    deidgroup$county[1467] <- "Alameda_CA"
    deidgroup$trumpvote[1467] <- 14.9
    deidgroup$county[1468] <- "New York_NY"
    deidgroup$trumpvote[1468] <- 10
    deidgroup$county[1469] <- "Middlesex_MA"
    deidgroup$trumpvote[1469] <- 28.2
    deidgroup$county[1470] <- "King_WA"
    deidgroup$trumpvote[1470] <- 21.7

# Analysis Overall Sample ----------------------------------------------------------
# Difference of Means tests-Reply at all
# Splitting Data by condition
Control_dataset_group <- deidgroup[deidgroup$condition == "Control", ]
Liberal_dataset_group <- deidgroup[deidgroup$condition == "Liberal", ]
Conservative_dataset_group <- deidgroup[deidgroup$condition == "Conservative", ]

# Liberal-Control Difference of Means- Overall
q <- na.omit(Liberal_dataset_group$replies)
p <- na.omit(Control_dataset_group$replies)
Liberal_Control_DoM_test_Reply_group <- t.test(q, p)
Liberal_Control_DoM_Reply_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Control_DoM_CI_Reply_group <- round(Liberal_Control_DoM_test_Reply_group$conf.int, digits = 2) 
Liberal_Control_DoM_T_Reply_group <- round(Liberal_Control_DoM_test_Reply_group$statistic, digits = 2)
Liberal_Control_DoM_p_Reply_group <- round(Liberal_Control_DoM_test_Reply_group$p.value, digits = 2)
Liberal_Control_DoM_n_Reply_group <- length(p) + length(q)

# Conservative-Control Difference of Means
q <- na.omit(Conservative_dataset_group$replies)
p <- na.omit(Control_dataset_group$replies)
Conservative_Control_DoM_test_Reply_group <- t.test(q, p)
Conservative_Control_DoM_Reply_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Conservative_Control_DoM_CI_Reply_group <- round(Conservative_Control_DoM_test_Reply_group$conf.int, digits = 2) 
Conservative_Control_DoM_T_Reply_group <- round(Conservative_Control_DoM_test_Reply_group$statistic, digits = 2)
Conservative_Control_DoM_p_Reply_group <- round(Conservative_Control_DoM_test_Reply_group$p.value, digits = 2)
Conservative_Control_DoM_n_Reply_group <- as.numeric(nrow(Conservative_dataset_group) + nrow(Control_dataset_group))
Conservative_Control_DoM_n_Reply_group <- length(p) + length(q)

# Liberal-Conservative Difference of Means
q <- na.omit(Liberal_dataset_group$replies)
p <- na.omit(Conservative_dataset_group$replies)
Liberal_Conservative_DoM_test_Reply_group <- t.test(q, p)
Liberal_Conservative_DoM_Reply_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Conservative_DoM_CI_Reply_group <- round(Liberal_Conservative_DoM_test_Reply_group$conf.int, digits = 2) 
Liberal_Conservative_DoM_T_Reply_group <- round(Liberal_Conservative_DoM_test_Reply_group$statistic, digits = 2)
Liberal_Conservative_DoM_p_Reply_group <- round(Liberal_Conservative_DoM_test_Reply_group$p.value, digits = 2)
Liberal_Conservative_DoM_n_Reply_group <- length(p) + length(q)

# Difference of Means Overall - Substantive Replies
# Liberal-Control Difference of Means- Overall
q <- na.omit(Liberal_dataset_group$substantive)
p <- na.omit(Control_dataset_group$substantive)
Liberal_Control_DoM_test_substantive_group <- t.test(as.numeric(q),as.numeric(p))
Liberal_Control_DoM_substantive_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Control_DoM_CI_substantive_group <- round(Liberal_Control_DoM_test_substantive_group$conf.int, digits = 2) 
Liberal_Control_DoM_T_substantive_group <- round(Liberal_Control_DoM_test_substantive_group$statistic, digits = 2)
Liberal_Control_DoM_p_substantive_group <- round(Liberal_Control_DoM_test_substantive_group$p.value, digits = 2)
Liberal_Control_DoM_n_substantive_group <- length(p) + length(q)

# Conservative-Control Difference of Means
q <- na.omit(Conservative_dataset_group$substantive)
p <- na.omit(Control_dataset_group$substantive)
Conservative_Control_DoM_test_substantive_group <- t.test(as.numeric(q), as.numeric(p))
Conservative_Control_DoM_substantive_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Conservative_Control_DoM_CI_substantive_group <- round(Conservative_Control_DoM_test_substantive_group$conf.int, digits = 2) 
Conservative_Control_DoM_T_substantive_group <- round(Conservative_Control_DoM_test_substantive_group$statistic, digits = 2)
Conservative_Control_DoM_p_substantive_group <- round(Conservative_Control_DoM_test_substantive_group$p.value, digits = 2)
Conservative_Control_DoM_n_substantive_group <- length(p) + length(q)

# Liberal-Conservative Difference of Means
q <- na.omit(Liberal_dataset_group$substantive)
p <- na.omit(Conservative_dataset_group$substantive)
Liberal_Conservative_DoM_test_substantive_group <- t.test(as.numeric(q),as.numeric(p))
Liberal_Conservative_DoM_substantive_group <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Conservative_DoM_CI_substantive_group <- round(Liberal_Conservative_DoM_test_substantive_group$conf.int, digits = 2) 
Liberal_Conservative_DoM_T_substantive_group <- round(Liberal_Conservative_DoM_test_substantive_group$statistic, digits = 2)
Liberal_Conservative_DoM_p_substantive_group <- round(Liberal_Conservative_DoM_test_substantive_group$p.value, digits = 2)
Liberal_Conservative_DoM_n_substantive_group <- length(p) + length(q)

# Difference of Means-Days to Reply
# Liberal-Control Difference of Means- Overall
q <- na.omit(Liberal_dataset_group$days)
p <- na.omit(Control_dataset_group$days)
Liberal_Control_DoM_test_days_group <- t.test(as.numeric(q),as.numeric(p))
Liberal_Control_DoM_days_group  <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Control_DoM_CI_days_group  <- round(Liberal_Control_DoM_test_days_group$conf.int, digits = 2) 
Liberal_Control_DoM_T_days_group  <- round(Liberal_Control_DoM_test_days_group$statistic, digits = 2)
Liberal_Control_DoM_p_days_group  <- round(Liberal_Control_DoM_test_days_group$p.value, digits = 2)
Liberal_Control_DoM_n_days_group  <- length(p) + length(q)

# Conservative-Control Difference of Means
q <- na.omit(Conservative_dataset_group$days)
p <- na.omit(Control_dataset_group$days)
Conservative_Control_DoM_test_days_group  <- t.test(as.numeric(q),as.numeric(p))
Conservative_Control_DoM_days_group  <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Conservative_Control_DoM_CI_days_group  <- round(Conservative_Control_DoM_test_days_group$conf.int, digits = 2) 
Conservative_Control_DoM_T_days_group  <- round(Conservative_Control_DoM_test_days_group$statistic, digits = 2)
Conservative_Control_DoM_p_days_group  <- round(Conservative_Control_DoM_test_days_group$p.value, digits = 2)
Conservative_Control_DoM_n_days_group  <- length(p) + length(q)

# Liberal-Conservative Difference of Means
q <- na.omit(Liberal_dataset_group$days)
p <- na.omit(Conservative_dataset_group$days)
Liberal_Conservative_DoM_test_days_group  <- t.test(as.numeric(q), as.numeric(p))
Liberal_Conservative_DoM_days_group  <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Liberal_Conservative_DoM_CI_days_group  <- round(Liberal_Conservative_DoM_test_days_group$conf.int, digits = 2) 
Liberal_Conservative_DoM_T_days_group  <- round(Liberal_Conservative_DoM_test_days_group$statistic, digits = 2)
Liberal_Conservative_DoM_p_days_group  <- round(Liberal_Conservative_DoM_test_days_group$p.value, digits = 2)
Liberal_Conservative_DoM_n_days_group  <- length(p) + length(q)

# Creating a New Dataset of Only Valid Replies
valid_replies <- deidgroup[deidgroup$replies == "1", ]

valid_Control_dataset_group <- valid_replies[valid_replies$condition == "Control", ]
valid_Liberal_dataset_group <- valid_replies[valid_replies$condition == "Liberal", ]
valid_Conservative_dataset_group <- valid_replies[valid_replies$condition == "Conservative", ]

# Difference of Means for Emails that Received A Reply at all
# Substantive Replies
# Liberal-Control Substantive Replies, Replied at all
q <- na.omit(valid_Liberal_dataset_group$substantive)
p <- na.omit(valid_Control_dataset_group$substantive)
Liberal_Control_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Conservative-Control Substantive Replies, Replied at all
q <- na.omit(valid_Conservative_dataset_group$substantive)
p <- na.omit(valid_Control_dataset_group$substantive)
Conservative_Control_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Liberal-Conservative Substantive Replies, Replied at all
q <- na.omit(valid_Conservative_dataset_group$substantive)
p <- na.omit(valid_Liberal_dataset_group$substantive)
Conservative_Liberal_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Days to Reply
# Liberal-Control Days to Reply, Replied at all
q <- na.omit(valid_Liberal_dataset_group$days)
p <- na.omit(valid_Control_dataset_group$days)
Liberal_Control_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Conservative-Control Days to Reply, Replied at all
q <- na.omit(valid_Conservative_dataset_group$days)
p <- na.omit(valid_Control_dataset_group$days)
Conservative_Control_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Liberal-Conservative Days to Reply, Replied at all
q <- na.omit(valid_Conservative_dataset_group$days)
p <- na.omit(valid_Liberal_dataset_group$days)
Conservative_Liberal_DoM_test <- t.test(as.numeric(q),as.numeric(p))

# Difference of Means Table 
dom_n_group <- c(Liberal_Control_DoM_n_Reply_group, 
           Conservative_Control_DoM_n_Reply_group, 
           Liberal_Conservative_DoM_n_Reply_group,
           
           Liberal_Control_DoM_n_substantive_group, 
           Conservative_Control_DoM_n_substantive_group, 
           Liberal_Conservative_DoM_n_substantive_group,
           
           Liberal_Control_DoM_n_days_group, 
           Conservative_Control_DoM_n_days_group, 
           Liberal_Conservative_DoM_n_days_group )

differences_of_means_group <- c(Liberal_Control_DoM_Reply_group,
                        Conservative_Control_DoM_Reply_group,
                        Liberal_Conservative_DoM_Reply_group,
                        
                        Liberal_Control_DoM_substantive_group,
                        Conservative_Control_DoM_substantive_group,
                        Liberal_Conservative_DoM_substantive_group,
                        
                        Liberal_Control_DoM_days_group,
                        Conservative_Control_DoM_days_group,
                        Liberal_Conservative_DoM_days_group)

dom_confidence_intervals_low_group <- c(round(Liberal_Control_DoM_test_Reply_group$conf.int[1], digits =2),
                               round(Conservative_Control_DoM_test_Reply_group$conf.int[1], digits =2), 
                               round(Liberal_Conservative_DoM_test_Reply_group$conf.int[1], digits =2),
                               
                               round(Liberal_Control_DoM_test_substantive_group$conf.int[1], digits =2),
                               round(Conservative_Control_DoM_test_substantive_group$conf.int[1], digits =2), 
                               round(Liberal_Conservative_DoM_test_substantive_group$conf.int[1], digits =2),
                               
                               round(Liberal_Control_DoM_test_days_group$conf.int[1], digits =2),
                               round(Conservative_Control_DoM_test_days_group$conf.int[1], digits =2), 
                               round(Liberal_Conservative_DoM_test_days_group$conf.int[1], digits =2))



dom_confidence_intervals_high_group <- c(round(Liberal_Control_DoM_test_Reply_group$conf.int[2], digits =2),
                                        round(Conservative_Control_DoM_test_Reply_group$conf.int[2], digits =2), 
                                        round(Liberal_Conservative_DoM_test_Reply_group$conf.int[2], digits =2),
                                        
                                        round(Liberal_Control_DoM_test_substantive_group$conf.int[2], digits =2),
                                        round(Conservative_Control_DoM_test_substantive_group$conf.int[2], digits =2), 
                                        round(Liberal_Conservative_DoM_test_substantive_group$conf.int[2], digits =2),
                                        
                                        round(Liberal_Control_DoM_test_days_group$conf.int[2], digits =2),
                                        round(Conservative_Control_DoM_test_days_group$conf.int[2], digits =2), 
                                        round(Liberal_Conservative_DoM_test_days_group$conf.int[2], digits =2))

dom_t_statistics_group <- c(Liberal_Control_DoM_T_Reply_group,
                    Conservative_Control_DoM_T_Reply_group,
                    Liberal_Conservative_DoM_T_Reply_group,
                    
                    Liberal_Control_DoM_T_substantive_group,
                    Conservative_Control_DoM_T_substantive_group,
                    Liberal_Conservative_DoM_T_substantive_group,
                    
                    Liberal_Control_DoM_T_days_group,
                    Conservative_Control_DoM_T_days_group,
                    Liberal_Conservative_DoM_T_days_group)

dom_p_values_group <- c(Liberal_Control_DoM_p_Reply_group,
                Conservative_Control_DoM_p_Reply_group,
                Liberal_Conservative_DoM_p_Reply_group,
                
                Liberal_Control_DoM_p_substantive_group,
                Conservative_Control_DoM_p_substantive_group,
                Liberal_Conservative_DoM_p_substantive_group,
                
                Liberal_Control_DoM_p_days_group,
                Conservative_Control_DoM_p_days_group,
                Liberal_Conservative_DoM_p_days_group)

# Difference of Means Latex Output Table
# domconfidenceintervals object contains only lower confidence interval bounds
# Insert brackets, commas, and upper confidence interval bounds in Latex manually 
# must adjust size in Latex (scalebox =.85)
library(Hmisc)
Test <- matrix(NA, 9, 5)
colnames(Test) <- c("n", "Diff. Means", "95% CI", 
                    "T-statistic", "p-value")
rownames(Test) <- c("Liberal-Control, Reply at All",
                    "Conservative-Control, Reply at All",
                    "Liberal-Conservative, Reply at All", 
                    
                    "Liberal-Control, Substantive Replies",
                    "Conservative-Control, Substantive Replies",
                    "Liberal-Conservative, Substantive Replies",
                    
                    "Liberal-Control, Days to Reply",
                    "Conservative-Control, Days to Reply",
                    "Liberal-Conservative, Days to Reply") 
Test[ ,1] <- dom_n_group
Test[ ,2] <- differences_of_means_group
Test[ ,3] <- dom_confidence_intervals_low_group
Test[ ,4] <- dom_t_statistics_group
Test[ ,5] <- dom_p_values_group
latex(Test, file = "")

# Logit Models for Overall Sample --------------------------------------------------------------------------
# Creating a south/non-south variable as the tables are too long with all 4 regions
deidgroup$south <- NA
deidgroup[, 7][deidgroup[, 8] == "North"] <- 0
deidgroup[, 7][deidgroup[, 8] == "South"] <- 1
deidgroup[, 7][deidgroup[, 8] == "Midwest"] <- 0
deidgroup[, 7][deidgroup[, 8] == "West"] <- 0

# Logit Model with No Controls-Reply at All
reply_base <-glm(as.numeric(replies) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = deidgroup, 
                 family = binomial(link = "logit"))

summary(reply_base)

# Logit Model with No Controls-Substantive
substantive_base <-glm(as.numeric(substantive) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = deidgroup, 
                 family = binomial(link = "logit"))

summary(substantive_base)

# Logit Model with Controls including school type
reply_controls_incl_type <-glm(as.numeric(replies) ~ 
                       + I(condition=="Liberal") 
                     + I(condition=="Conservative")
                     + I(setting=="urban")
                     + I(setting=="rural")
                     + endowment + enrollment + ranking
                     + I(south==1)
                     + I(religious==1)
                     + as.factor(num_school_type)
                     + trumpvote,
                     data = deidgroup, 
                     family = binomial(link = "logit"))

summary(reply_controls_incl_type)

# Logit Model  Reply at all with Controls leaving out school type as tables are too long
reply_controls <-glm(as.numeric(replies) ~ 
                                 + I(condition=="Liberal") 
                               + I(condition=="Conservative")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(south==1)
                               + I(religious==1)
                               + trumpvote,
                               data = deidgroup, 
                               family = binomial(link = "logit"))

summary(reply_controls)

# Logit Model  substantive reply with Controls leaving out school type as tables are too long
substantive_controls <-glm(as.numeric(substantive) ~ 
                       + I(condition=="Liberal") 
                     + I(condition=="Conservative")
                     + I(setting=="urban")
                     + I(setting=="rural")
                     + endowment + enrollment + ranking
                     + I(south==1)
                     + I(religious==1)
                     + trumpvote,
                     data = deidgroup, 
                     family = binomial(link = "logit"))

summary(substantive_controls)

# Logit Model with Controls + Interactions, incl school type, plus south, and religious interactions
reply_interactions_incl_type <-glm(as.numeric(replies) ~ 
                           + I(condition=="Liberal") 
                         + I(condition=="Conservative")
                         + I(setting=="urban")
                         + I(setting=="rural")
                         + endowment + enrollment + ranking
                         + I(south==1)
                         + I(religious==1)
                         + as.factor(num_school_type)
                         + trumpvote
                         + trumpvote * I(condition=="Liberal")
                         + trumpvote * I(condition=="Conservative"),
                         data = deidgroup, family = binomial(link = "logit"))

summary(reply_interactions_incl_type)

# Logit Model Reply at All with Controls + Interactions without school type
reply_interactions <-glm(as.numeric(replies) ~ 
                                     + I(condition=="Liberal") 
                                   + I(condition=="Conservative")
                                   + I(setting=="urban")
                                   + I(setting=="rural")
                                   + endowment + enrollment + ranking
                                   + I(south==1)
                                   + I(religious==1)
                                   + trumpvote
                                   + trumpvote * I(condition=="Liberal")
                                   + trumpvote * I(condition=="Conservative"),
                                   data = deidgroup, family = binomial(link = "logit"))

summary(reply_interactions)

# Logit Model Substantive Reply with Controls + Interactions without type
substantive_interactions <-glm(as.numeric(substantive) ~ 
                           + I(condition=="Liberal") 
                         + I(condition=="Conservative")
                         + I(setting=="urban")
                         + I(setting=="rural")
                         + endowment + enrollment + ranking
                         + I(south==1)
                         + I(religious==1)
                         + trumpvote
                         + trumpvote * I(condition=="Liberal")
                         + trumpvote * I(condition=="Conservative"),
                         data = deidgroup, family = binomial(link = "logit"))

summary(substantive_interactions)

# Logit Model Substantive Reply with Controls + Interactions without type
substantive_interactions_incltype <-glm(as.numeric(substantive) ~ 
                                 + I(condition=="Liberal") 
                               + I(condition=="Conservative")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(south==1)
                               + I(religious==1)
                               + trumpvote
                               + trumpvote * I(condition=="Liberal")
                               + trumpvote * I(condition=="Conservative"),
                               data = deidgroup, family = binomial(link = "logit"))

summary(substantive_interactions_incltype)

# OLS Models of Days to Reply
# Base Model
days_base <-lm(as.numeric(days) ~ 
  + I(condition=="Liberal")
  + I(condition=="Conservative"),
data = deidgroup)

summary(days_base)

# OLS Model with Controls, Days to Reply, not including school type
days_controls <-lm(as.numeric(days) ~ 
                         + I(condition=="Liberal") 
                       + I(condition=="Conservative")
                       + I(setting=="urban")
                       + I(setting=="rural")
                       + endowment + enrollment + ranking
                       + I(south==1)
                       + I(religious==1)
                   + trumpvote,
                       data = deidgroup)

summary(days_controls)

# OLS Model with Controls, Days to Reply, including school type
days_controls_inclschool <-lm(as.numeric(days) ~ 
                     + I(condition=="Liberal") 
                   + I(condition=="Conservative")
                   + I(setting=="urban")
                   + I(setting=="rural")
                   + endowment + enrollment + ranking
                   + I(south==1)
                   + I(religious==1)
                   + as.factor(num_school_type)
                   + trumpvote,
                   data = deidgroup)

summary(days_controls_inclschool)


# OLS Model with Controls + Interactions, Days to Reply, including school type 
days_interactions_inclschool <-lm(as.numeric(days) ~ 
                         + I(condition=="Liberal") 
                       + I(condition=="Conservative")
                       + I(setting=="urban")
                       + I(setting=="rural")
                       + endowment + enrollment + ranking
                       + I(south==1)
                       + I(religious==1)
                       + as.factor(num_school_type)
                       + trumpvote
                       + trumpvote * I(condition=="Liberal")
                       + trumpvote * I(condition=="Conservative"),
                       data = deidgroup)

summary(days_interactions_inclschool)

# OLS Model with Controls + Interactions, Days to Reply-not including school type 
days_interactions <-lm(as.numeric(days) ~ 
                                 + I(condition=="Liberal") 
                               + I(condition=="Conservative")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(south==1)
                               + I(religious==1)
                               + trumpvote
                               + trumpvote * I(condition=="Liberal")
                               + trumpvote * I(condition=="Conservative"),
                               data = deidgroup)

summary(days_interactions)

# Stargazer Model Tables
install.packages("stargazer")
library("stargazer")

# Renaming Models Shorter to go in stargazer
r <- reply_base
r_c <- reply_controls
s <- substantive_base
s_c <- substantive_controls
d <- days_base
d_c <- days_controls

Table_One <- stargazer(r, r_c, s, s_c, d, d_c,
                       covariate.labels = c("Liberal Condition", 
                                            "Conservative Condition",
                                            "Urban Setting",
                                            "Rural Setting",
                                            "Endowment",
                                            "Enrollment",
                                            "Ranking",
                                            "Southern",
                                            "Religious",
                                            "Trump Vote"),
                       dep.var.labels = c("Reply at All", 
                                          "Substantive Reply", "Days to Reply"),
                       star.cutoffs = c(.05, .01, NA),
                       #star.char    = c("*", "**", ""),         
                       notes.append     = FALSE,
                       notes            = "*$p<0.05$; **$p<0.01$")


# Table F1 in Online Appendix
Table_F1 <- stargazer(reply_interactions,
                      substantive_interactions,
                      days_interactions,
                      covariate.labels = c("Liberal Condition", 
                                           "Conservative Condition",
                                           "Urban Setting",
                                           "Rural Setting",
                                           "Endowment",
                                           "Enrollment",
                                           "Ranking",
                                           "Southern",
                                           "Religious",
                                           "Trump Vote",
                                           "Trump Vote * Liberal Condition",
                                           "Trump Vote * Conservative Condition"),
                      dep.var.labels = "Reply at All",
                      star.cutoffs = c(.05, .01, NA),
                      #star.char    = c("*", "**", ""),         
                      notes.append     = FALSE,
                      notes            = "*$p<0.05$; **$p<0.01$")


replies_logittable <- stargazer(reply_base, 
                                reply_controls, 
                                reply_interactions,
                                covariate.labels = c("Liberal Condition", 
                                                     "Conservative Condition",
                                                     "Urban Setting",
                                                     "Rural Setting",
                                                     "Endowment",
                                                     "Enrollment",
                                                     "Ranking",
                                                     "Southern",
                                                     "Religious",
                                                     "Trump Vote",
                                                     "Trump Vote * Liberal Condition",
                                                     "Trump Vote * Conservative Condition"),
                                dep.var.labels = "Reply at All",
                                star.cutoffs = c(.05, .01, NA),
                                #star.char    = c("*", "**", ""),         
                                notes.append     = FALSE,
                                notes            = "*$p<0.05$; **$p<0.01$")

                                
substantive_logittable <- stargazer(substantive_base, 
                                    substantive_controls, 
                                    substantive_interactions,
                                    covariate.labels = c("Liberal Condition", 
                                                         "Conservative Condition",
                                                         "Urban Setting",
                                                         "Rural Setting",
                                                         "Endowment",
                                                         "Enrollment",
                                                         "Ranking",
                                                         "Southern",
                                                         "Religious",
                                                         "Trump Vote",
                                                         "Trump Vote * Liberal Condition",
                                                         "Trump Vote * Conservative Condition"),
                                    dep.var.labels = "Substantive Reply",
                                    star.cutoffs = c(.05, .01, NA),
                                    #star.char    = c("*", "**", ""),         
                                    notes.append     = FALSE,
                                    notes            = "*$p<0.05$; **$p<0.01$")

# need to \resizebox{1.375\textwidth}{!} in latex to make it fit on a page
days_logittable <- stargazer(days_base, 
                                 days_controls,
                                 days_interactions,
                                 covariate.labels = c("Liberal Condition", 
                                                      "Conservative Condition",
                                                      "Urban Setting",
                                                      "Rural Setting",
                                                      "Endowment",
                                                      "Enrollment",
                                                      "Ranking",
                                                      "Southern",
                                                      "Religious",
                                                      "Trump Vote",
                                                      "Trump Vote * Liberal Condition",
                                                      "Trump Vote * Conservative Condition"),
                                 dep.var.labels = "Days to Reply",
                                 star.cutoffs = c(.05, .01, NA),
                                 #star.char    = c("*", "**", ""),         
                                 notes.append     = FALSE,
                                 notes            = "*$p<0.05$; **$p<0.01$")



                                 


# e.g of how to F statistic and residual std error omitted or table is too wide
days_appendix_table <- stargazer(days_base, days_controls,days_interactions,
                                 omit.stat=c("f", "ser"),
                                column.sep.width = "-15pt")

# Testing for Multicollinearity with Variance Inflation Factor
install.packages("car")
library(car)
vif_replies <- vif(reply_controls)
vif_substantive <- vif(substantive_controls)
vif_days <- vif(days_controls)

# Cox Proportional Hazard Model for Right-Censoring, Days to Reply
install.packages("survival")
library("survival")
group_hazard <- coxph(Surv(days, replies) ~  
                        I(condition=="Liberal") 
                        + I(condition=="Conservative"),
                        data = deidgroup)

summary(group_hazard)

library("stargazer")
student_group_hazard_table <- stargazer(group_hazard, align=TRUE, 
                                        covariate.labels = c("Liberal Condition", "Conservative Condition"),
                                        dep.var.labels   = "Days to Reply",
                                        type="text", apply.coef = exp, p.auto = FALSE, 
                                        t.auto = FALSE, digits = 3, report=('vc*p'))

# Two-Stage Heckman Selection Model, Days to Reply
install.packages("sampleSelection")
library("sampleSelection")

two_stage_selection = selection(replies ~ I(condition=="Liberal") 
                                + I(condition=="Conservative") + enrollment,
                                days ~ I(condition=="Liberal") 
                                + I(condition=="Conservative"),
                                data = deidgroup,
                            method = '2step')

summary(two_stage_selection)

selection_table <- stargazer(two_stage_selection)

# Logit Model with Enrollment x Treatment Interaction
# to test for Hawthorne effect
reply_Hawthorne <-glm(as.numeric(replied) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative")
                 + enrollment
                 + (I(condition=="Liberal")*enrollment)
                 + (I(condition=="Conservative")*enrollment),
                 data = deidgroup, 
                 family = binomial(link = "logit"))

summary(reply_Hawthorne)

library(stargazer)
logit_interaction_table <- stargazer(reply_Hawthorne,
                                   dep.var.labels=c("responsiveness"),
                                   covariate.labels=c("Liberal", "Conservative", "Enrollment", "Liberal x Enrollment",
                                                      "Conservative x Enrollment"))

reply_Hawthorne_LibArt <-glm(as.numeric(replied) ~ 
                        + I(condition=="Liberal") 
                      + I(condition=="Conservative")
                      + enrollment
                      + (I(condition=="Liberal")*enrollment)
                      + (I(condition=="Conservative")*enrollment),
                      data = LibArt, 
                      family = binomial(link = "logit"))

summary(reply_Hawthorne_LibArt)

library(stargazer)
logit_interaction_libart <- stargazer(reply_Hawthorne_LibArt,
                                   dep.var.labels=c("responsiveness"),
                                   covariate.labels=c("Liberal", "Conservative", "Enrollment", "Liberal x Enrollment",
                                                      "Conservative x Enrollment"))

# OLS Models Overall Sample Reply at All
# OLS Model with No Controls
OLS_results <-lm(as.numeric(replied) ~ 
                             + I(condition=="Liberal")
                           + I(condition=="Conservative"),
                           data = deidgroup)

summary(OLS_results)

# OLS Model with Controls 
OLS_results_controls <-lm(as.numeric(replied) ~ 
                                      + I(condition=="Liberal") 
                                    + I(condition=="Conservative")
                                    + I(setting=="urban")
                                    + I(setting=="rural")
                                    + endowment + enrollment + ranking
                                    + I(south==1)
                                    + I(religious==1)
                                    + as.factor(num_school_type),
                                    data = deidgroup)

summary(OLS_results_controls)

# OLS Model with EnrollmentxTreatment Interaction
# to test for Hawthorne effect
OLS_Hawthorne <-lm(as.numeric(replied) ~ 
                        + I(condition=="Liberal") 
                      + I(condition=="Conservative")
                      + enrollment
                      + (I(condition=="Liberal")*enrollment)
                      + (I(condition=="Conservative")*enrollment),
                      data = deidgroup)

summary(OLS_Hawthorne)

# Logit overall sample interactive
logit_Hawthorne <-glm(as.numeric(replied) ~ 
                     + I(condition=="Liberal") 
                   + I(condition=="Conservative")
                   + enrollment
                   + (I(condition=="Liberal")*enrollment)
                   + (I(condition=="Conservative")*enrollment),
                   data = deidgroup)

summary(logit_Hawthorne)

logit_Hawthorne_LibArt <-glm(as.numeric(replied) ~ 
                        + I(condition=="Liberal") 
                      + I(condition=="Conservative")
                      + enrollment
                      + (I(condition=="Liberal")*enrollment)
                      + (I(condition=="Conservative")*enrollment),
                      data = LibArt)

summary(logit_Hawthorne_LibArt)


# OLD (June 4, 2019) Table 3: Logistic Regression Results (includes interactive model)
# Must adjust (scalebox =.55) to fit, take out label and caption in Latex
library(stargazer)
logit_table <- stargazer(reply_base, reply_controls, reply_interactions,
                         title = "Logistic Regression Results",
                         dep.var.labels=c("esponsiveness","responsiveness", "responsiveness"),
                         covariate.labels=c("liberal", "conservative", "urban", "rural",
                                            "endowment", "enrollment", "ranking", "South",
                                            "religious", "Liberal Arts", "Regional Universities",
                                            "Regional Colleges", "urban x liberal", "urban x conservative",
                                            "rural x liberal", "rural x conservative", "religious x conservative",
                                            "religious x liberal", "South x liberal", "South x conservative"))

# NEW (Aug 13, 2019) Table 3
# Table of Logit Models of Responsiveness, Overall Sample
library(stargazer)
logit_table_three <- stargazer(reply_base, reply_controls,
                               title = "Logistic Regression Results",
                               dep.var.labels=c("Responsiveness","Responsiveness"),
                               covariate.labels=c("Liberal", "Conservative", "Urban", "Rural",
                                                  "Endowment", "Enrollment", "Ranking", "South",
                                                  "Religious", "Liberal Arts", "Regional Universities",
                                                  "Regional Colleges"))

# Table of OLS Models of Responsiveness, Overall Sample
# with controls
library(stargazer)
OLS_table <- stargazer(OLS_results, OLS_results_controls,
                                 title = "OLS Regression Results",
                                 dep.var.labels=c("Responsiveness","Responsiveness"),
                                 covariate.labels=c("Liberal", "Conservative", "Urban", "Rural",
                                                    "Endowment", "Enrollment", "Ranking", "South",
                                                    "Religious", "Liberal Arts", "Regional Universities",
                                                    "Regional Colleges"))

OLS_table_base <- stargazer(OLS_results,
                       dep.var.labels=c("Responsiveness"),
                       covariate.labels=c("Liberal", "Conservative"))

logit_table_libarts <- stargazer(reply_base,
                            dep.var.labels=c("Responsiveness"),
                            covariate.labels=c("Liberal", "Conservative"))

# Sub-analyses ------------------------------------------------------------------------------------------
# National Liberal Arts Colleges
# National Liberal Arts Datasets
Liberal_Arts_Colleges_Control_dataset <- Control_dataset[Control_dataset$type == "National Liberal Arts College", ]
Liberal_Arts_Colleges_Conservative_dataset <- Conservative_dataset[Conservative_dataset$type == "National Liberal Arts College", ]
Liberal_Arts_Colleges_Liberal_dataset <- Liberal_dataset[Liberal_dataset$type == "National Liberal Arts College", ]

# Liberal-Control Difference of Means Among National Liberal Arts Colleges
q <- na.omit(Liberal_Arts_Colleges_Liberal_dataset$replied)
p <- na.omit(Liberal_Arts_Colleges_Control_dataset$replied)
LibArts_Liberal_Control_DoM_test <- t.test(q, p)
LibArts_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
LibArts_Liberal_Control_DoM_CI <- round(LibArts_Liberal_Control_DoM_test$conf.int, digits = 2) 
LibArts_Liberal_Control_DoM_T <- round(LibArts_Liberal_Control_DoM_test$statistic, digits = 2)
LibArts_Liberal_Control_DoM_p <- round(LibArts_Liberal_Control_DoM_test$p.value, digits = 2)
LibArts_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among National Liberal Arts Colleges
q <- na.omit(Liberal_Arts_Colleges_Conservative_dataset$replied)
p <- na.omit(Liberal_Arts_Colleges_Control_dataset$replied)
LibArts_Conservative_Control_DoM_test <- t.test(q, p)
LibArts_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
LibArts_Conservative_Control_DoM_CI <- round(LibArts_Conservative_Control_DoM_test$conf.int, digits = 2) 
LibArts_Conservative_Control_DoM_T <- round(LibArts_Conservative_Control_DoM_test$statistic, digits = 2)
LibArts_Conservative_Control_DoM_p <- round(LibArts_Conservative_Control_DoM_test$p.value, digits = 2)
LibArts_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among National Liberal Arts Colleges
q <- na.omit(Liberal_Arts_Colleges_Liberal_dataset$replied)
p <- na.omit(Liberal_Arts_Colleges_Conservative_dataset$replied)
LibArts_Liberal_Conservative_DoM_test <- t.test(q, p)
LibArts_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
LibArts_Liberal_Conservative_DoM_CI <- round(LibArts_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
LibArts_Liberal_Conservative_DoM_T <- round(LibArts_Liberal_Conservative_DoM_test$statistic, digits = 2)
LibArts_Liberal_Conservative_DoM_p <- round(LibArts_Liberal_Conservative_DoM_test$p.value, digits = 2)
LibArts_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Religious Schools
# Religious Schools Datasets
Religious_Colleges_Control_dataset <- Control_dataset[Control_dataset$religious == 1, ]
Religious_Colleges_Liberal_dataset <- Liberal_dataset[Liberal_dataset$religious == 1, ]
Religious_Colleges_Conservative_dataset <- Conservative_dataset[Conservative_dataset$religious == 1, ]

# Liberal-Control Difference of Means Among Religious Schools
q <- na.omit(Religious_Colleges_Liberal_dataset$replied)
p <- na.omit(Religious_Colleges_Control_dataset$replied)
Religious_Liberal_Control_DoM_test <- t.test(q, p)
Religious_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Religious_Liberal_Control_DoM_CI <- round(Religious_Liberal_Control_DoM_test$conf.int, digits = 2) 
Religious_Liberal_Control_DoM_T <- round(Religious_Liberal_Control_DoM_test$statistic, digits = 2)
Religious_Liberal_Control_DoM_p <- round(Religious_Liberal_Control_DoM_test$p.value, digits = 2)
Religious_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among Religious Schools
q <- na.omit(Religious_Colleges_Conservative_dataset$replied)
p <- na.omit(Religious_Colleges_Control_dataset$replied)
Religious_Conservative_Control_DoM_test <- t.test(q, p)
Religious_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Religious_Conservative_Control_DoM_CI <- round(Religious_Conservative_Control_DoM_test$conf.int, digits = 2) 
Religious_Conservative_Control_DoM_T <- round(Religious_Conservative_Control_DoM_test$statistic, digits = 2)
Religious_Conservative_Control_DoM_p <- round(Religious_Conservative_Control_DoM_test$p.value, digits = 2)
Religious_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among Religious Schools
q <- na.omit(Religious_Colleges_Liberal_dataset$replied)
p <- na.omit(Religious_Colleges_Conservative_dataset$replied)
Religious_Liberal_Conservative_DoM_test <- t.test(q, p)
Religious_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Religious_Liberal_Conservative_DoM_CI <- round(Religious_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
Religious_Liberal_Conservative_DoM_T <- round(Religious_Liberal_Conservative_DoM_test$statistic, digits = 2)
Religious_Liberal_Conservative_DoM_p <- round(Religious_Liberal_Conservative_DoM_test$p.value, digits = 2)
Religious_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Non-Religious Schools
# Non-Religious Schools Datasets
NonReligious_Colleges_Control_dataset <- Control_dataset[Control_dataset$religious == 0, ]
NonReligious_Colleges_Liberal_dataset <- Liberal_dataset[Liberal_dataset$religious == 0, ]
NonReligious_Colleges_Conservative_dataset <- Conservative_dataset[Conservative_dataset$religious == 0, ]

# Liberal-Control Difference of Means Among NonReligious Schools
q <- na.omit(NonReligious_Colleges_Liberal_dataset$replied)
p <- na.omit(NonReligious_Colleges_Control_dataset$replied)
NonReligious_Liberal_Control_DoM_test <- t.test(q, p)
NonReligious_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonReligious_Liberal_Control_DoM_CI <- round(NonReligious_Liberal_Control_DoM_test$conf.int, digits = 2) 
NonReligious_Liberal_Control_DoM_T <- round(NonReligious_Liberal_Control_DoM_test$statistic, digits = 2)
NonReligious_Liberal_Control_DoM_p <- round(NonReligious_Liberal_Control_DoM_test$p.value, digits = 2)
NonReligious_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among NonReligious Schools
q <- na.omit(NonReligious_Colleges_Conservative_dataset$replied)
p <- na.omit(NonReligious_Colleges_Control_dataset$replied)
NonReligious_Conservative_Control_DoM_test <- t.test(q, p)
NonReligious_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonReligious_Conservative_Control_DoM_CI <- round(NonReligious_Conservative_Control_DoM_test$conf.int, digits = 2) 
NonReligious_Conservative_Control_DoM_T <- round(NonReligious_Conservative_Control_DoM_test$statistic, digits = 2)
NonReligious_Conservative_Control_DoM_p <- round(NonReligious_Conservative_Control_DoM_test$p.value, digits = 2)
NonReligious_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among NonReligious Schools
q <- na.omit(NonReligious_Colleges_Liberal_dataset$replied)
p <- na.omit(NonReligious_Colleges_Conservative_dataset$replied)
NonReligious_Liberal_Conservative_DoM_test <- t.test(q, p)
NonReligious_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonReligious_Liberal_Conservative_DoM_CI <- round(NonReligious_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
NonReligious_Liberal_Conservative_DoM_T <- round(NonReligious_Liberal_Conservative_DoM_test$statistic, digits = 2)
NonReligious_Liberal_Conservative_DoM_p <- round(NonReligious_Liberal_Conservative_DoM_test$p.value, digits = 2)
NonReligious_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Southern Schools
# Southern Schools Datasets
Southern_Control_dataset <- Control_dataset[Control_dataset$region == "South", ]
Southern_Liberal_dataset <- Liberal_dataset[Liberal_dataset$region == "South", ]
Southern_Conservative_dataset <- Conservative_dataset[Conservative_dataset$region == "South", ]

# Liberal-Control Difference of Means Among Southern Schools
q <- na.omit(Southern_Liberal_dataset$replied)
p <- na.omit(Southern_Control_dataset$replied)
Southern_Liberal_Control_DoM_test <- t.test(q, p)
Southern_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Southern_Liberal_Control_DoM_CI <- round(Southern_Liberal_Control_DoM_test$conf.int, digits = 2) 
Southern_Liberal_Control_DoM_T <- round(Southern_Liberal_Control_DoM_test$statistic, digits = 2)
Southern_Liberal_Control_DoM_p <- round(Southern_Liberal_Control_DoM_test$p.value, digits = 2)
Southern_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among Southern Schools
q <- na.omit(Southern_Conservative_dataset$replied)
p <- na.omit(Southern_Control_dataset$replied)
Southern_Conservative_Control_DoM_test <- t.test(q, p)
Southern_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Southern_Conservative_Control_DoM_CI <- round(Southern_Conservative_Control_DoM_test$conf.int, digits = 2) 
Southern_Conservative_Control_DoM_T <- round(Southern_Conservative_Control_DoM_test$statistic, digits = 2)
Southern_Conservative_Control_DoM_p <- round(Southern_Conservative_Control_DoM_test$p.value, digits = 2)
Southern_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among Southern Schools
q <- na.omit(Southern_Liberal_dataset$replied)
p <- na.omit(Southern_Conservative_dataset$replied)
Southern_Liberal_Conservative_DoM_test <- t.test(q, p)
Southern_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Southern_Liberal_Conservative_DoM_CI <- round(Southern_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
Southern_Liberal_Conservative_DoM_T <- round(Southern_Liberal_Conservative_DoM_test$statistic, digits = 2)
Southern_Liberal_Conservative_DoM_p <- round(Southern_Liberal_Conservative_DoM_test$p.value, digits = 2)
Southern_Liberal_Conservative_DoM_n <- length(p) + length(q)

# NonSouthern Schools
# NonSouthern Schools Datasets
NonSouthern_Control_dataset <- Control_dataset[Control_dataset$region != "South", ]
NonSouthern_Liberal_dataset <- Liberal_dataset[Liberal_dataset$region != "South", ]
NonSouthern_Conservative_dataset <- Conservative_dataset[Conservative_dataset$region != "South", ]

# Liberal-Control Difference of Means Among NonSouthern Schools
q <- na.omit(NonSouthern_Liberal_dataset$replied)
p <- na.omit(NonSouthern_Control_dataset$replied)
NonSouthern_Liberal_Control_DoM_test <- t.test(q, p)
NonSouthern_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonSouthern_Liberal_Control_DoM_CI <- round(NonSouthern_Liberal_Control_DoM_test$conf.int, digits = 2) 
NonSouthern_Liberal_Control_DoM_T <- round(NonSouthern_Liberal_Control_DoM_test$statistic, digits = 2)
NonSouthern_Liberal_Control_DoM_p <- round(NonSouthern_Liberal_Control_DoM_test$p.value, digits = 2)
NonSouthern_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among NonSouthern Schools
q <- na.omit(NonSouthern_Conservative_dataset$replied)
p <- na.omit(NonSouthern_Control_dataset$replied)
NonSouthern_Conservative_Control_DoM_test <- t.test(q, p)
NonSouthern_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonSouthern_Conservative_Control_DoM_CI <- round(NonSouthern_Conservative_Control_DoM_test$conf.int, digits = 2) 
NonSouthern_Conservative_Control_DoM_T <- round(NonSouthern_Conservative_Control_DoM_test$statistic, digits = 2)
NonSouthern_Conservative_Control_DoM_p <- round(NonSouthern_Conservative_Control_DoM_test$p.value, digits = 2)
NonSouthern_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among NonSouthern Schools
q <- na.omit(NonSouthern_Liberal_dataset$replied)
p <- na.omit(NonSouthern_Conservative_dataset$replied)
NonSouthern_Liberal_Conservative_DoM_test <- t.test(q, p)
NonSouthern_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
NonSouthern_Liberal_Conservative_DoM_CI <- round(NonSouthern_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
NonSouthern_Liberal_Conservative_DoM_T <- round(NonSouthern_Liberal_Conservative_DoM_test$statistic, digits = 2)
NonSouthern_Liberal_Conservative_DoM_p <- round(NonSouthern_Liberal_Conservative_DoM_test$p.value, digits = 2)
NonSouthern_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Urban Schools
# Urban Schools Datasets
Urban_Control_dataset <- Control_dataset[Control_dataset$setting == "urban", ]
Urban_Liberal_dataset <- Liberal_dataset[Liberal_dataset$setting == "urban", ]
Urban_Conservative_dataset <- Conservative_dataset[Conservative_dataset$setting == "urban", ]

# Liberal-Control Difference of Means Among Urban Schools
q <- na.omit(Urban_Liberal_dataset$replied)
p <- na.omit(Urban_Control_dataset$replied)
Urban_Liberal_Control_DoM_test <- t.test(q, p)
Urban_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Urban_Liberal_Control_DoM_CI <- round(Urban_Liberal_Control_DoM_test$conf.int, digits = 2) 
Urban_Liberal_Control_DoM_T <- round(Urban_Liberal_Control_DoM_test$statistic, digits = 2)
Urban_Liberal_Control_DoM_p <- round(Urban_Liberal_Control_DoM_test$p.value, digits = 2)
Urban_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among Urban Schools
q <- na.omit(Urban_Conservative_dataset$replied)
p <- na.omit(Urban_Control_dataset$replied)
Urban_Conservative_Control_DoM_test <- t.test(q, p)
Urban_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Urban_Conservative_Control_DoM_CI <- round(Urban_Conservative_Control_DoM_test$conf.int, digits = 2) 
Urban_Conservative_Control_DoM_T <- round(Urban_Conservative_Control_DoM_test$statistic, digits = 2)
Urban_Conservative_Control_DoM_p <- round(Urban_Conservative_Control_DoM_test$p.value, digits = 2)
Urban_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among Urban Schools
q <- na.omit(Urban_Liberal_dataset$replied)
p <- na.omit(Urban_Conservative_dataset$replied)
Urban_Liberal_Conservative_DoM_test <- t.test(q, p)
Urban_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Urban_Liberal_Conservative_DoM_CI <- round(Urban_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
Urban_Liberal_Conservative_DoM_T <- round(Urban_Liberal_Conservative_DoM_test$statistic, digits = 2)
Urban_Liberal_Conservative_DoM_p <- round(Urban_Liberal_Conservative_DoM_test$p.value, digits = 2)
Urban_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Rural Schools
# Rural Schools Datasets
Rural_Control_dataset <- Control_dataset[Control_dataset$setting == "rural", ]
Rural_Liberal_dataset <- Liberal_dataset[Liberal_dataset$setting == "rural", ]
Rural_Conservative_dataset <- Conservative_dataset[Conservative_dataset$setting == "rural", ]

# Liberal-Control Difference of Means Among Rural Schools
q <- na.omit(Rural_Liberal_dataset$replied)
p <- na.omit(Rural_Control_dataset$replied)
Rural_Liberal_Control_DoM_test <- t.test(q, p)
Rural_Liberal_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Rural_Liberal_Control_DoM_CI <- round(Rural_Liberal_Control_DoM_test$conf.int, digits = 2) 
Rural_Liberal_Control_DoM_T <- round(Rural_Liberal_Control_DoM_test$statistic, digits = 2)
Rural_Liberal_Control_DoM_p <- round(Rural_Liberal_Control_DoM_test$p.value, digits = 2)
Rural_Liberal_Control_DoM_n <- length(p) + length(q)

# Conservative-Control Difference of Means Among Rural Schools
q <- na.omit(Rural_Conservative_dataset$replied)
p <- na.omit(Rural_Control_dataset$replied)
Rural_Conservative_Control_DoM_test <- t.test(q, p)
Rural_Conservative_Control_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Rural_Conservative_Control_DoM_CI <- round(Rural_Conservative_Control_DoM_test$conf.int, digits = 2) 
Rural_Conservative_Control_DoM_T <- round(Rural_Conservative_Control_DoM_test$statistic, digits = 2)
Rural_Conservative_Control_DoM_p <- round(Rural_Conservative_Control_DoM_test$p.value, digits = 2)
Rural_Conservative_Control_DoM_n <- length(p) + length(q)

# Liberal-Conservative Difference of Means Among Rural Schools
q <- na.omit(Rural_Liberal_dataset$replied)
p <- na.omit(Rural_Conservative_dataset$replied)
Rural_Liberal_Conservative_DoM_test <- t.test(q, p)
Rural_Liberal_Conservative_DoM <- round(mean(as.numeric(q))- mean(as.numeric(p)), digits = 2)
Rural_Liberal_Conservative_DoM_CI <- round(Rural_Liberal_Conservative_DoM_test$conf.int, digits = 2) 
Rural_Liberal_Conservative_DoM_T <- round(Rural_Liberal_Conservative_DoM_test$statistic, digits = 2)
Rural_Liberal_Conservative_DoM_p <- round(Rural_Liberal_Conservative_DoM_test$p.value, digits = 2)
Rural_Liberal_Conservative_DoM_n <- length(p) + length(q)

# Difference of Means, Subanalysis Table ----------------------------------------------------------
dom_n <- c(Liberal_Control_DoM_n, Conservative_Control_DoM_n, Liberal_Conservative_DoM_n, 
           LibArts_Liberal_Control_DoM_n, LibArts_Conservative_Control_DoM_n, LibArts_Liberal_Conservative_DoM_n,
           Religious_Liberal_Control_DoM_n,Religious_Conservative_Control_DoM_n, Religious_Liberal_Conservative_DoM_n,
           NonReligious_Liberal_Control_DoM_n, NonReligious_Conservative_Control_DoM_n,
           NonReligious_Liberal_Conservative_DoM_n, Southern_Liberal_Control_DoM_n,
           Southern_Conservative_Control_DoM_n, Southern_Liberal_Conservative_DoM_n,
           NonSouthern_Liberal_Control_DoM_n, NonSouthern_Conservative_Control_DoM_n,
           NonSouthern_Liberal_Conservative_DoM_n, Urban_Liberal_Control_DoM_n,
           Urban_Conservative_Control_DoM_n, Urban_Liberal_Conservative_DoM_n,
           Rural_Liberal_Control_DoM_n, Rural_Conservative_Control_DoM_n,
           Rural_Liberal_Conservative_DoM_n)

differencesofmeans <- c(Liberal_Control_DoM, Conservative_Control_DoM, Liberal_Conservative_DoM,
                        LibArts_Liberal_Control_DoM, LibArts_Conservative_Control_DoM,
                        LibArts_Liberal_Conservative_DoM, Religious_Liberal_Control_DoM,
                        Religious_Conservative_Control_DoM, Religious_Liberal_Conservative_DoM,
                        NonReligious_Liberal_Control_DoM, NonReligious_Conservative_Control_DoM,
                        NonReligious_Liberal_Conservative_DoM, Southern_Liberal_Control_DoM,
                        Southern_Conservative_Control_DoM, Southern_Liberal_Conservative_DoM,
                        NonSouthern_Liberal_Control_DoM, NonSouthern_Conservative_Control_DoM,
                        NonSouthern_Liberal_Conservative_DoM, Urban_Liberal_Control_DoM,
                        Urban_Conservative_Control_DoM, Urban_Liberal_Conservative_DoM,
                        Rural_Liberal_Control_DoM, Rural_Conservative_Control_DoM,
                        Rural_Liberal_Conservative_DoM)

domconfidenceintervalslow <- c(round(Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(Conservative_Control_DoM_test$conf.int[1], digits =2), 
                               round(Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(LibArts_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(LibArts_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(LibArts_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(Religious_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(Religious_Conservative_Control_DoM_test$conf.int[1], digits=2),
                               round(Religious_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(NonReligious_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(NonReligious_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(NonReligious_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(Southern_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(Southern_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(Southern_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(NonSouthern_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(NonSouthern_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(NonSouthern_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(Urban_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(Urban_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(Urban_Liberal_Conservative_DoM_test$conf.int[1], digits =2),
                               
                               round(Rural_Liberal_Control_DoM_test$conf.int[1], digits =2),
                               round(Rural_Conservative_Control_DoM_test$conf.int[1], digits =2),
                               round(Rural_Liberal_Conservative_DoM_test$conf.int[1], digits =2))

domconfidenceintervalshigh <- c(round(Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(Conservative_Control_DoM_test$conf.int[2], digits =2), 
                                round(Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(LibArts_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(LibArts_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(LibArts_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(Religious_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(Religious_Conservative_Control_DoM_test$conf.int[2], digits=2),
                                round(Religious_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(NonReligious_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(NonReligious_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(NonReligious_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(Southern_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(Southern_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(Southern_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(NonSouthern_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(NonSouthern_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(NonSouthern_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(Urban_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(Urban_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(Urban_Liberal_Conservative_DoM_test$conf.int[2], digits =2),
                                
                                round(Rural_Liberal_Control_DoM_test$conf.int[2], digits =2),
                                round(Rural_Conservative_Control_DoM_test$conf.int[2], digits =2),
                                round(Rural_Liberal_Conservative_DoM_test$conf.int[2], digits =2))

domtstatistics <- c(Liberal_Control_DoM_T, Conservative_Control_DoM_T, Liberal_Conservative_DoM_T,
                    LibArts_Liberal_Control_DoM_T, LibArts_Conservative_Control_DoM_T,
                    LibArts_Liberal_Conservative_DoM_T, Religious_Liberal_Control_DoM_T,
                    Religious_Conservative_Control_DoM_T, Religious_Liberal_Conservative_DoM_T,
                    NonReligious_Liberal_Control_DoM_T, NonReligious_Conservative_Control_DoM_T,
                    NonReligious_Liberal_Conservative_DoM_T, Southern_Liberal_Control_DoM_T,
                    Southern_Conservative_Control_DoM_T, Southern_Liberal_Conservative_DoM_T,
                    NonSouthern_Liberal_Control_DoM_T, NonSouthern_Conservative_Control_DoM_T,
                    NonSouthern_Liberal_Conservative_DoM_T, Urban_Liberal_Control_DoM_T,
                    Urban_Conservative_Control_DoM_T, Urban_Liberal_Conservative_DoM_T,
                    Rural_Liberal_Control_DoM_T, Rural_Conservative_Control_DoM_T,
                    Rural_Liberal_Conservative_DoM_T)

dompvalues <- c(Liberal_Control_DoM_p, Conservative_Control_DoM_p, Liberal_Conservative_DoM_p,
                LibArts_Liberal_Control_DoM_p, LibArts_Conservative_Control_DoM_p,
                LibArts_Liberal_Conservative_DoM_p, Religious_Liberal_Control_DoM_p,
                Religious_Conservative_Control_DoM_p, Religious_Liberal_Conservative_DoM_p,
                NonReligious_Liberal_Control_DoM_p, NonReligious_Conservative_Control_DoM_p,
                NonReligious_Liberal_Conservative_DoM_p, Southern_Liberal_Control_DoM_p,
                Southern_Conservative_Control_DoM_p, Southern_Liberal_Conservative_DoM_p,
                NonSouthern_Liberal_Control_DoM_p, NonSouthern_Conservative_Control_DoM_p,
                NonSouthern_Liberal_Conservative_DoM_p, Urban_Liberal_Control_DoM_p,
                Urban_Conservative_Control_DoM_p, Urban_Liberal_Conservative_DoM_p,
                Rural_Liberal_Control_DoM_p, Rural_Conservative_Control_DoM_p,
                Rural_Liberal_Conservative_DoM_p)

# Difference of Means Latex Output Table
# domconfidenceintervals object contains only lower confidence interval bounds
# Insert brackets, commas, and upper confidence interval bounds in Latex manually 
# must adjust size in Latex (scalebox =.85)
library(Hmisc)
Test <- matrix(NA, 24, 5)
colnames(Test) <- c("n", "Diff. Means", "95% CI", 
                    "T-statistic", "p-value")
rownames(Test) <- c("Liberal-Control, Overall",
                    "Conservative-Control, Overall",
                    "Liberal-Conservative, Overall", 
                    "Liberal-Control, Liberal Arts",
                    "Conservative-Control, Liberal Arts",
                    "Liberal-Conservative, Liberal Arts",
                    "Liberal-Control, Religious",
                    "Conservative-Control, Religious",
                    "Liberal-Conservative, Religious",
                    "Liberal-Control, NonReligious",
                    "Conservative-Control, NonReligious",
                    "Liberal-Conservative, NonReligious",
                    "Liberal-Control, Southern",
                    "Conservative-Control, Southern",
                    "Liberal-Conservative, Southern",
                    "Liberal-Control, NonSouthern",
                    "Conservative-Control, NonSouthern",
                    "Liberal-Conservative, NonSouthern",
                    "Liberal-Control, Urban",
                    "Conservative-Control, Urban",
                    "Liberal-Conservative, Urban",
                    "Liberal-Control, Rural",
                    "Conservative-Control, Rural",
                    "Liberal-Conservative, Rural") 
Test[ ,1] <- dom_n
Test[ ,2] <- differencesofmeans
Test[ ,3] <- domconfidenceintervalslow
Test[ ,4] <- domtstatistics
Test[ ,5] <- dompvalues
latex(Test, file = "")

# Observed Response sample sizes, response rates and Standard Deviations---------------------------------------------
# N Overall
Overall_Liberal_n <- length(na.omit(Liberal_dataset_group$replies))
Overall_Conservative_n <- length(na.omit(Conservative_dataset_group$replies))
Overall_Control_n <- length(na.omit(Control_dataset_group$replies))

# RR Overall 
Observed_rr_overall <- round(mean(na.omit(deidgroup$replies)), digits=2)
Observed_rr_overall_Liberal <- round(mean(na.omit(Liberal_dataset_group$replies)), digits=2)
Observed_rr_overall_Conservative <- round(mean(na.omit(Conservative_dataset_group$replies)), digits=2)
Observed_rr_overall_Control <- round(mean(na.omit(Control_dataset_group$replies)), digits=2)

# Plot of Response Rates, Standard Errors and N
# Standard Error, Overall
SE_Overall_Liberal <- sqrt((Observed_rr_overall_Liberal*(1-Observed_rr_overall_Liberal))/Overall_Liberal_n)
SE_Overall_Conservative <- sqrt((Observed_rr_overall_Conservative*(1-Observed_rr_overall_Conservative))/Overall_Conservative_n)
SE_Overall_Control <- sqrt((Observed_rr_overall_Control*(1-Observed_rr_overall_Control))/Overall_Control_n)

# Plot of Response Rates +/- 1.96*Standard Error
RR_vector <- c(Observed_rr_overall_Liberal, Observed_rr_overall_Control, Observed_rr_overall_Conservative)
labels <- c("\nLiberal \nn=465", "\nControl \nn=465", "\nConservative \nn=469")
Condition <- c(1,2,3)

# 95% Normal Theory Confidence Intervals
up.ci.overall <- c(Observed_rr_overall_Liberal + 1.96*SE_Overall_Liberal,
                   Observed_rr_overall_Control + 1.96*SE_Overall_Control, 
                   Observed_rr_overall_Conservative + 1.96*SE_Overall_Conservative)

low.ci.overall <- c(Observed_rr_overall_Liberal - 1.96*SE_Overall_Liberal,
                    Observed_rr_overall_Control - 1.96*SE_Overall_Control, 
                    Observed_rr_overall_Conservative - 1.96*SE_Overall_Conservative)

# Plot of Reply at all Response Rates and Confidence Intervals
RR_plot <- plot(Condition, RR_vector, xlab="Experimental Group", 
                ylab="Response Rate", ylim = c(0.5, 0.8), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall, Condition, up.ci.overall, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels)

# SD Overall
Observed_rr_overall_Liberal_sd <- round(sd(na.omit(Liberal_dataset$replied)), digits=2)
Observed_rr_overall_Conservative_sd <- round(sd(na.omit(Conservative_dataset$replied)), digits=2)
Observed_rr_overall_Control_sd <- round(sd(na.omit(Control_dataset$replied)), digits=2)

# Substantive Reply Plot, overall sample
# N Overall Substantive
Overall_Liberal_n_sub <- length(na.omit(Liberal_dataset_group$substantive))
Overall_Conservative_n_sub <- length(na.omit(Conservative_dataset_group$substantive))
Overall_Control_n_sub <- length(na.omit(Control_dataset_group$substantive))

# RR Overall 
Observed_rr_overall_sub <- round(mean(na.omit(deidgroup$substantive)), digits=2)
Observed_rr_overall_Liberal_sub <- round(mean(na.omit(Liberal_dataset_group$substantive)), digits=2)
Observed_rr_overall_Conservative_sub <- round(mean(na.omit(Conservative_dataset_group$substantive)), digits=2)
Observed_rr_overall_Control_sub <- round(mean(na.omit(Control_dataset_group$substantive)), digits=2)

# Plot of Response Rates, Standard Errors and N
# Standard Error, Overall
SE_Overall_Liberal_sub <- sqrt((Observed_rr_overall_Liberal_sub*(1-Observed_rr_overall_Liberal_sub))/Overall_Liberal_n_sub)
SE_Overall_Conservative_sub <- sqrt((Observed_rr_overall_Conservative_sub*(1-Observed_rr_overall_Conservative_sub))/Overall_Conservative_n_sub)
SE_Overall_Control_sub <- sqrt((Observed_rr_overall_Control_sub*(1-Observed_rr_overall_Control_sub))/Overall_Control_n_sub)

# Plot of Response Rates +/- 1.96*Standard Error
RR_vector_sub <- c(Observed_rr_overall_Liberal_sub, 
               Observed_rr_overall_Control_sub, 
               Observed_rr_overall_Conservative_sub)
labels <- c("\nLiberal \nn=465", "\nControl \nn=465", "\nConservative \nn=469")
Condition <- c(1,2,3)

# 95% Normal Theory Confidence Intervals
up.ci.overall.sub <- c(Observed_rr_overall_Liberal_sub + 1.96*SE_Overall_Liberal_sub,
                   Observed_rr_overall_Control_sub + 1.96*SE_Overall_Control_sub, 
                   Observed_rr_overall_Conservative_sub + 1.96*SE_Overall_Conservative_sub)

low.ci.overall.sub <- c(Observed_rr_overall_Liberal_sub - 1.96*SE_Overall_Liberal_sub,
                    Observed_rr_overall_Control_sub - 1.96*SE_Overall_Control_sub, 
                    Observed_rr_overall_Conservative_sub - 1.96*SE_Overall_Conservative_sub)

# Plot of Response Rates and Confidence Intervals
RR_plot_sub <- plot(Condition, RR_vector_sub, xlab="Experimental Group", 
                ylab="Substantive Response Rate", ylim = c(0.5, 0.8), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall.sub, Condition, up.ci.overall.sub, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels)

# SD Overall
Observed_rr_overall_Liberal_sd_sub <- round(sd(na.omit(Liberal_dataset$substantive)), digits=2)
Observed_rr_overall_Conservative_sd_sub <- round(sd(na.omit(Conservative_dataset$substantive)), digits=2)
Observed_rr_overall_Control_sd_sub <- round(sd(na.omit(Control_dataset$substantive)), digits=2)

# Days to Reply Plot, overall sample
# N Overall Days
Overall_Liberal_n_days <- length(na.omit(Liberal_dataset_group$days))
Overall_Conservative_n_days <- length(na.omit(Conservative_dataset_group$days))
Overall_Control_n_days <- length(na.omit(Control_dataset_group$days))

# RR Overall 
Observed_rr_overall_Liberal_days <- round(mean(na.omit(Liberal_dataset_group$days)), digits=2)
Observed_rr_overall_Conservative_days <- round(mean(na.omit(Conservative_dataset_group$days)), digits=2)
Observed_rr_overall_Control_days <- round(mean(na.omit(Control_dataset_group$days)), digits=2)

# Standard Error of Days to Reply, Overall
SE_Overall_Liberal_days <- sd(na.omit(Liberal_dataset_group$days))/sqrt(Overall_Liberal_n_days)
SE_Overall_Conservative_days <- sd(na.omit(Conservative_dataset_group$days))/sqrt(Overall_Conservative_n_days)
SE_Overall_Control_days <- sd(na.omit(Control_dataset_group$days))/sqrt(Overall_Control_n_days)

# Plot of Response Rates +/- 1.96*Standard Error
RR_vector_days <- c(Observed_rr_overall_Liberal_days, 
                   Observed_rr_overall_Control_days, 
                   Observed_rr_overall_Conservative_days)
labels <- c("\nLiberal \nn=465", "\nControl \nn=465", "\nConservative \nn=469")
Condition <- c(1,2,3)

# 95% Normal Theory Confidence Intervals
up.ci.overall.days <- c(Observed_rr_overall_Liberal_days + 1.96*SE_Overall_Liberal_days,
                       Observed_rr_overall_Control_days + 1.96*SE_Overall_Control_days, 
                       Observed_rr_overall_Conservative_days + 1.96*SE_Overall_Conservative_days)

low.ci.overall.days <- c(Observed_rr_overall_Liberal_days - 1.96*SE_Overall_Liberal_days,
                        Observed_rr_overall_Control_days - 1.96*SE_Overall_Control_days, 
                        Observed_rr_overall_Conservative_days - 1.96*SE_Overall_Conservative_days)

# Plot of Response Rates and Confidence Intervals
RR_plot_days <- plot(Condition, RR_vector_days, xlab="Experimental Group", 
                    ylab="Days to Reply", ylim = c(5, 20), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall.days, Condition, up.ci.overall.days, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels)

# SD Overall
Observed_rr_overall_Liberal_sd_days <- round(sd(na.omit(Liberal_dataset_group$days)), digits=2)
Observed_rr_overall_Conservative_sd_days <- round(sd(na.omit(Conservative_dataset_group$days)), digits=2)
Observed_rr_overall_Control_sd_days <- round(sd(na.omit(Control_dataset_group$days)), digits=2)

# Figure 2 in Political Behavior paper
# 3 pane figure Reply at All, Substantive Reply, Days to Reply
par(mfrow=c(3,1))

# Plot of Reply at all Response Rates and Confidence Intervals
RR_plot <- plot(Condition, RR_vector, xlab="Experimental Group", 
                ylab="Reply at All Response Rate", ylim = c(0.5, 0.7), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall, Condition, up.ci.overall, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels, cex.lab=1.2)

# Plot of Substantive Response Rates and Confidence Intervals
RR_plot_sub <- plot(Condition, RR_vector_sub, xlab="Experimental Group", 
                    ylab="Substantive Response Rate", ylim = c(0.5, 0.7), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall.sub, Condition, up.ci.overall.sub, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels, cex.lab=1.2)

# Plot of Days to Reply and Confidence Intervals
RR_plot_days <- plot(Condition, RR_vector_days, xlab="Experimental Group", 
                     ylab="Days to Reply", ylim = c(10, 15), xaxt = 'n', family = "serif" )
arrows(Condition, low.ci.overall.days, Condition, up.ci.overall.days, length=0.05, angle=90, code=3)
axis(1, at=1:3, family = "serif", labels=labels)

















# Sub-analyses ---------------------------------------------------------
# N National Liberal Arts Colleges
LibArts_Liberal_n <- length(na.omit(Liberal_Arts_Colleges_Liberal_dataset$replied))
LibArts_Conservative_n <- length(na.omit(Liberal_Arts_Colleges_Conservative_dataset$replied))
LibArts_Control_n <- length(na.omit(Liberal_Arts_Colleges_Control_dataset$replied))

# RR National Liberal Arts Colleges
Observed_rr_LibArts_Liberal <- round(mean(na.omit(Liberal_Arts_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_LibArts_Conservative <- round(mean(na.omit(Liberal_Arts_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_LibArts_Control <- round(mean(na.omit(Liberal_Arts_Colleges_Control_dataset$replied)), digits=2)

# SD National Liberal Arts Colleges
Observed_rr_LibArts_Liberal_sd <- round(sd(na.omit(Liberal_Arts_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_LibArts_Conservative_sd <- round(sd(na.omit(Liberal_Arts_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_LibArts_Control_sd <- round(sd(na.omit(Liberal_Arts_Colleges_Control_dataset$replied)), digits=2)

# N Southern Colleges
South_Liberal_n <- length(na.omit(Southern_Liberal_dataset$replied))
South_Conservative_n <- length(na.omit(Southern_Conservative_dataset$replied))
South_Control_n <- length(na.omit(Southern_Control_dataset$replied))

# RR Southern Colleges
Observed_rr_Southern_Liberal <- round(mean(na.omit(Southern_Liberal_dataset$replied)), digits=2)
Observed_rr_Southern_Conservative <- round(mean(na.omit(Southern_Conservative_dataset$replied)), digits=2)
Observed_rr_Southern_Control <- round(mean(na.omit(Southern_Control_dataset$replied)), digits=2)

# SD Southern Colleges
Observed_rr_Southern_Liberal_sd <- round(sd(na.omit(Southern_Liberal_dataset$replied)), digits=2)
Observed_rr_Southern_Conservative_sd <- round(sd(na.omit(Southern_Conservative_dataset$replied)), digits=2)
Observed_rr_Southern_Control_sd <- round(sd(na.omit(Southern_Control_dataset$replied)), digits=2)

# N NonSouthern Colleges
NonSouth_Liberal_n <- length(na.omit(NonSouthern_Liberal_dataset$replied))
NonSouth_Conservative_n <- length(na.omit(NonSouthern_Conservative_dataset$replied))
NonSouth_Control_n <- length(na.omit(NonSouthern_Control_dataset$replied))

# RR NonSouthern Colleges
Observed_rr_NonSouthern_Liberal <- round(mean(na.omit(NonSouthern_Liberal_dataset$replied)), digits=2)
Observed_rr_NonSouthern_Conservative <- round(mean(na.omit(NonSouthern_Conservative_dataset$replied)), digits=2)
Observed_rr_NonSouthern_Control <- round(mean(na.omit(NonSouthern_Control_dataset$replied)), digits=2)

# SD NonSouthern Colleges
Observed_rr_NonSouthern_Liberal_sd <- round(sd(na.omit(NonSouthern_Liberal_dataset$replied)), digits=2)
Observed_rr_NonSouthern_Conservative_sd <- round(sd(na.omit(NonSouthern_Conservative_dataset$replied)), digits=2)
Observed_rr_NonSouthern_Control_sd <- round(sd(na.omit(NonSouthern_Control_dataset$replied)), digits=2)

# N Religious Colleges
Religious_Liberal_n <- length(na.omit(Religious_Colleges_Liberal_dataset$replied))
Religious_Conservative_n <- length(na.omit(Religious_Colleges_Conservative_dataset$replied))
Religious_Control_n <- length(na.omit(Religious_Colleges_Control_dataset$replied))

# RR Religious Colleges
Observed_rr_Religious_Liberal <- round(mean(na.omit(Religious_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_Religious_Conservative <- round(mean(na.omit(Religious_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_Religious_Control <- round(mean(na.omit(Religious_Colleges_Control_dataset$replied)), digits=2)

# SD Religious Colleges
Observed_rr_Religious_Liberal_sd <- round(sd(na.omit(Religious_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_Religious_Conservative_sd <- round(sd(na.omit(Religious_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_Religious_Control_sd <- round(sd(na.omit(Religious_Colleges_Control_dataset$replied)), digits=2)

# N NonReligious Colleges
NonReligious_Liberal_n <- length(na.omit(NonReligious_Colleges_Liberal_dataset$replied))
NonReligious_Conservative_n <- length(na.omit(NonReligious_Colleges_Conservative_dataset$replied))
NonReligious_Control_n <- length(na.omit(NonReligious_Colleges_Control_dataset$replied))

# RR NonReligious Colleges
Observed_rr_NonReligious_Liberal <- round(mean(na.omit(NonReligious_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_NonReligious_Conservative <- round(mean(na.omit(NonReligious_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_NonReligious_Control <- round(mean(na.omit(NonReligious_Colleges_Control_dataset$replied)), digits=2)

# SD NonReligious Colleges
Observed_rr_NonReligious_Liberal_sd <- round(sd(na.omit(NonReligious_Colleges_Liberal_dataset$replied)), digits=2)
Observed_rr_NonReligious_Conservative_sd <- round(sd(na.omit(NonReligious_Colleges_Conservative_dataset$replied)), digits=2)
Observed_rr_NonReligious_Control_sd <- round(sd(na.omit(NonReligious_Colleges_Control_dataset$replied)), digits=2)

# N Urban Colleges
Urban_Liberal_n <- length(na.omit(Urban_Liberal_dataset$replied))
Urban_Conservative_n <- length(na.omit(Urban_Conservative_dataset$replied))
Urban_Control_n <- length(na.omit(Urban_Control_dataset$replied))

# RR Urban Colleges
Observed_rr_Urban_Liberal <- round(mean(na.omit(Urban_Liberal_dataset$replied)), digits=2)
Observed_rr_Urban_Conservative <- round(mean(na.omit(Urban_Conservative_dataset$replied)), digits=2)
Observed_rr_Urban_Control <- round(mean(na.omit(Urban_Control_dataset$replied)), digits=2)

# SD Urban Colleges
Observed_rr_Urban_Liberal_sd <- round(sd(na.omit(Urban_Liberal_dataset$replied)), digits=2)
Observed_rr_Urban_Conservative_sd <- round(sd(na.omit(Urban_Conservative_dataset$replied)), digits=2)
Observed_rr_Urban_Control_sd <- round(sd(na.omit(Urban_Control_dataset$replied)), digits=2)

# N Rural Colleges
Rural_Liberal_n <- length(na.omit(Rural_Liberal_dataset$replied))
Rural_Conservative_n <- length(na.omit(Rural_Conservative_dataset$replied))
Rural_Control_n <- length(na.omit(Rural_Control_dataset$replied))

# RR Rural Colleges
Observed_rr_Rural_Liberal <- round(mean(na.omit(Rural_Liberal_dataset$replied)), digits=2)
Observed_rr_Rural_Conservative <- round(mean(na.omit(Rural_Conservative_dataset$replied)), digits=2)
Observed_rr_Rural_Control <- round(mean(na.omit(Rural_Control_dataset$replied)), digits=2)

# SD Rural Colleges
Observed_rr_Rural_Liberal_sd <- round(sd(na.omit(Rural_Liberal_dataset$replied)), digits=2)
Observed_rr_Rural_Conservative_sd <- round(sd(na.omit(Rural_Conservative_dataset$replied)), digits=2)
Observed_rr_Rural_Control_sd <- round(sd(na.omit(Rural_Control_dataset$replied)), digits=2)

# Combining all sample sizes, observed response rates, and standard deviations into vectors for table
# see line 2915 for Table 1 Option B, which uses standard errors instead of standard deviations
n_liberal <- c(Overall_Liberal_n, LibArts_Liberal_n, South_Liberal_n, NonSouth_Liberal_n, Religious_Liberal_n,
               NonReligious_Liberal_n, Urban_Liberal_n, Rural_Liberal_n)

n_control <- c(Overall_Control_n, LibArts_Control_n, South_Control_n, NonSouth_Control_n, Religious_Control_n,
               NonReligious_Control_n, Urban_Control_n, Rural_Control_n)

n_conservative <- c(Overall_Conservative_n, LibArts_Conservative_n, South_Conservative_n, NonSouth_Conservative_n, 
                    Religious_Conservative_n, NonReligious_Conservative_n, Urban_Conservative_n, Rural_Conservative_n)

observed_rrs_liberal <- c(Observed_rr_overall_Liberal, Observed_rr_LibArts_Liberal, Observed_rr_Southern_Liberal,
                          Observed_rr_NonSouthern_Liberal, Observed_rr_Religious_Liberal, 
                          Observed_rr_NonReligious_Liberal, Observed_rr_Urban_Liberal, Observed_rr_Rural_Liberal)

observed_rrs_control <- c(Observed_rr_overall_Control, Observed_rr_LibArts_Control, Observed_rr_Southern_Control,
                          Observed_rr_NonSouthern_Control, Observed_rr_Religious_Control, 
                          Observed_rr_NonReligious_Control, Observed_rr_Urban_Control, Observed_rr_Rural_Control)

observed_rrs_conservative <- c(Observed_rr_overall_Conservative, Observed_rr_LibArts_Conservative,
                               Observed_rr_Southern_Conservative, Observed_rr_NonSouthern_Conservative, 
                               Observed_rr_Religious_Conservative, Observed_rr_NonReligious_Conservative, 
                               Observed_rr_Urban_Conservative, Observed_rr_Rural_Conservative)

observed_sd_liberal <- c(Observed_rr_overall_Liberal_sd, Observed_rr_LibArts_Liberal_sd, 
                         Observed_rr_Southern_Liberal_sd,Observed_rr_NonSouthern_Liberal_sd,
                         Observed_rr_Religious_Liberal_sd,Observed_rr_NonReligious_Liberal_sd,
                         Observed_rr_Urban_Liberal_sd, Observed_rr_Rural_Liberal_sd)

observed_sd_control <- c(Observed_rr_overall_Control_sd, Observed_rr_LibArts_Control_sd,
                         Observed_rr_Southern_Control_sd, Observed_rr_NonSouthern_Control_sd,
                         Observed_rr_Religious_Control_sd, Observed_rr_NonReligious_Control_sd,
                         Observed_rr_Urban_Control_sd, Observed_rr_Rural_Control_sd)


observed_sd_conservative <- c(Observed_rr_overall_Conservative_sd, Observed_rr_LibArts_Conservative_sd,
                              Observed_rr_Southern_Conservative_sd, Observed_rr_NonSouthern_Conservative_sd, 
                              Observed_rr_Religious_Conservative_sd, Observed_rr_NonReligious_Conservative_sd, 
                              Observed_rr_Urban_Conservative_sd, Observed_rr_Rural_Conservative_sd)

# Old Table 1: Observed Response Rates Across Conditions and by School Characteristics
library(Hmisc)
Sample <- matrix(NA, 8, 3)
colnames(Sample) <- c("Liberal Condition", "Control Condition", 
                      "Conservative Condition")
rownames(Sample) <- c("overall", "Liberal Arts", "South", "Non-South", "Religious", "Non-Religious", "Urban", "Rural") 
Sample[ ,1] <- observed_rrs_liberal
Sample[ ,2] <- observed_rrs_control
Sample[ ,3] <- observed_rrs_conservative
latex(Sample, file = "")

# New (Aug 13, 2019)
# Table 1 Option A: Observed Response Rates Across Conditions and by School Characteristics 
# with n and Std. Deviation
library(Hmisc)
Sample <- matrix(NA, 8, 9)
colnames(Sample) <- c("Lib. \n n", "Contr. \n n", "Conserv. \n n", 
                      "Lib. \n RR", "Contr. \n RR", "Conserv. \n RR", 
                      "Lib. \n SD", "Contr. \n SD", "Conserv. \n SD")
rownames(Sample) <- c("Overall", "Liberal Arts", "South", "Non-South", "Religious", "Non-Religious", "Urban", "Rural") 
Sample[ ,1] <- n_liberal
Sample[ ,2] <- n_control
Sample[ ,3] <- n_conservative
Sample[ ,4] <- observed_rrs_liberal
Sample[ ,5] <- observed_rrs_control
Sample[ ,6] <- observed_rrs_conservative
Sample[ ,7] <- observed_sd_liberal
Sample[ ,8] <- observed_sd_control
Sample[ ,9] <- observed_sd_conservative
latex(Sample, file = "")

# Predicted Probabilities of Response ------------------------------------------------------------------------
# Model for calculations of predicted probability of response in overall sample
reply_base <-glm(as.numeric(replies) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = deidgroup, 
                 family = binomial(link = "logit"))

summary(reply_base)

# Predicted Probability of Replying to the Liberal Student, Overall Sample
x.Liberal <- c(1, 1, 0)
z.Liberal <- sum(reply_base$coef * x.Liberal)
pp_Liberal_overall <- plogis(z.Liberal) 












# Predicted Probabilities of Response Based on Various Values of TrumpVote
# Model for calculations of predicted probability of response in overall sample
replyy <-glm(as.numeric(replies) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative")
                 + trumpvote,
                 data = deidgroup, 
                 family = binomial(link = "logit"))

summary(replyy)

# Predicted Probability of Replying to the Liberal Student
x.Liberal <- c(1, 1, 0, 82)
z.Liberal <- sum(replyy$coef * x.Liberal)
pp_Liberal_overall <- plogis(z.Liberal) 

# Predicted Probability of Replying to the Conservative Student, Overall Sample
x.Conservative.o <- c(1, 0, 1, 80)
z.Conservative.o <- sum(replyy$coef * x.Conservative.o)
pp_Conservative_overall <- plogis(z.Conservative.o) 


# Predicted Probability of Replying to the Control Student, Overall Sample
x.Control.o <- c(1, 0, 0, 80)
z.Control.o <- sum(replyy$coef * x.Control.o)
pp_Control_overall <- plogis(z.Control.o) 

# Marginal Standardization
install.packages("risks")
library(risks)
install.packages("crayon")
library(crayon)

replies_margstd <- riskdiff(formula = replies ~  
                          condition
                        + I(setting=="urban")
                        + I(setting=="rural")
                        + endowment + enrollment + ranking
                        + I(south==1)
                        + I(religious==1)
                        + trumpvote
                        + trumpvote * I(condition=="Liberal")
                        + trumpvote * I(condition=="Conservative"), 
                        data = deidgroup, 
                        approach = "margstd_delta")
summary(replies_margstd)

substantive_margstd <- riskdiff(formula = substantive ~  
                              condition
                            + I(setting=="urban")
                            + I(setting=="rural")
                            + endowment + enrollment + ranking
                            + I(south==1)
                            + I(religious==1)
                            + trumpvote
                            + trumpvote * I(condition=="Liberal")
                            + trumpvote * I(condition=="Conservative"), 
                            data = deidgroup, 
                            approach = "margstd_delta")
summary(substantive_margstd)







# Liberal Arts Colleges Dataset
LibArt <- deidgroup[deidgroup$type == "National Liberal Arts College", ]
LibArt_n <- nrow(LibArt)

# Balance Tests- Liberal Arts Colleges
# College characteristics predict being in the Liberal Condition among Liberal Arts Colleges
liberal_balance_libart <-glm(as.numeric(Liberal) ~ 
                               + I(setting=="urban")
                             + I(setting=="rural")
                             + endowment + enrollment + ranking
                             + I(region=="North") 
                             + I(region=="South") 
                             + I(region=="West") 
                             + I(religious==1),
                             data = LibArt, 
                             family = binomial(link = "logit"))

summary(liberal_balance_libart)

# College characteristics predict being in the Control Condition among Liberal Arts Colleges
control_balance_libart <-glm(as.numeric(Control) ~ 
                               + I(setting=="urban")
                             + I(setting=="rural")
                             + endowment + enrollment + ranking
                             + I(region=="North") 
                             + I(region=="South") 
                             + I(region=="West") 
                             + I(religious==1),
                             data = LibArt, 
                             family = binomial(link = "logit"))

summary(control_balance_libart)

# College characteristics predict being in Conservative Condition, Liberal Arts
conservative_balance_libart <-glm(as.numeric(Conservative) ~ 
                                    + I(setting=="urban")
                                  + I(setting=="rural")
                                  + endowment + enrollment + ranking
                                  + I(region=="North") 
                                  + I(region=="South") 
                                  + I(region=="West") 
                                  + I(religious==1),
                                  data = LibArt, 
                                  family = binomial(link = "logit"))

summary(conservative_balance_libart)

# Tables A7-A9 In the Paper
# Tables 10, 11, & 12: Balance Tests for National Liberal Arts Colleges (all emails sent)
# Table 10: Balance Test, National Liberal Arts Colleges- Liberal Treatment (all emails sent)
# Table A7 In the Paper
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(liberal_balance_libart$coefficients), digits = 2)
Variables[ ,2] <- round(summary(liberal_balance_libart)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(liberal_balance_libart)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Table 11: Balance Tests, National Liberal Arts Colleges- Conservative Treatment (all emails sent)
# A8
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(conservative_balance_libart$coefficients), digits = 2)
Variables[ ,2] <- round(summary(conservative_balance_libart)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(conservative_balance_libart)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Table 12: Balance Tests, National Liberal Arts Colleges- Control Condition (all emails sent)
# A9
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(control_balance_libart$coefficients), digits = 2)
Variables[ ,2] <- round(summary(control_balance_libart)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(control_balance_libart)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Balance Tests for National Liberal Arts Colleges with valid replies
# (automatic replies and undeliverable emails excluded)
# Creating a dataset of Liberal Arts Colleges with Valid Replies
LibArt_exclude <- LibArt[LibArt$replied != "NA", ]
n_LibArt_exclude <- nrow(LibArt_exclude)

# Any College characteristics predict being in Liberal Treatment?
# (National Liberal Arts Colleges, valid replies only)
liberal_balance_libart_exclude <-glm(as.numeric(Liberal) ~ 
                                       + I(setting=="urban")
                                     + I(setting=="rural")
                                     + endowment + enrollment + ranking
                                     + I(region=="North") 
                                     + I(region=="South") 
                                     + I(region=="West") 
                                     + I(religious==1),
                                     data = LibArt_exclude, 
                                     family = binomial(link = "logit"))

summary(liberal_balance_libart_exclude)

# Any College characteristics predict being in Conservative Treatment?
# (National Liberal Arts Colleges, valid replies only)
conservative_balance_libart_exclude <-glm(as.numeric(Conservative) ~ 
                                            + I(setting=="urban")
                                          + I(setting=="rural")
                                          + endowment + enrollment + ranking
                                          + I(region=="North") 
                                          + I(region=="South") 
                                          + I(region=="West") 
                                          + I(religious==1),
                                          data = LibArt_exclude, 
                                          family = binomial(link = "logit"))

summary(conservative_balance_libart_exclude)

# Any College characteristics predict being in Control Condition?
# (National Liberal Arts Colleges, valid replies only)
control_balance_libart_exclude <-glm(as.numeric(Control) ~ 
                                       + I(setting=="urban")
                                     + I(setting=="rural")
                                     + endowment + enrollment + ranking
                                     + I(region=="North") 
                                     + I(region=="South") 
                                     + I(region=="West") 
                                     + I(religious==1),
                                     data = LibArt_exclude, 
                                     family = binomial(link = "logit"))

summary(control_balance_libart_exclude)

# Table 13: Balance Test, National Liberal Arts Colleges- Liberal Treatment (non-valid replies excluded)
# A10
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(liberal_balance_libart_exclude$coefficients), digits = 2)
Variables[ ,2] <- round(summary(liberal_balance_libart_exclude)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(liberal_balance_libart_exclude)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Table 14: Balance Test, National Liberal Arts Colleges- Conservative Treatment 
# (non-valid replies excluded)
# A11
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(conservative_balance_libart_exclude$coefficients), digits = 2)
Variables[ ,2] <- round(summary(conservative_balance_libart_exclude)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(conservative_balance_libart_exclude)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Table 15: Balance Test, National Liberal Arts Colleges- Control Condition
# (non-valid replies excluded)
# A12
library(Hmisc)
Variables <- matrix(NA, 10 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","urban","rural", "endowment", "enrollment", 
                         "ranking", "North", "South", "West",
                         "religious") 
Variables[ ,1] <- round(as.numeric(control_balance_libart_exclude$coefficients), digits = 2)
Variables[ ,2] <- round(summary(control_balance_libart_exclude)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(control_balance_libart_exclude)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Liberal Arts Colleges Logit, no controls
libarts_logit <-glm(as.numeric(replied) ~ 
                     + I(condition=="Liberal") 
                   + I(condition=="Conservative"),
                   data = LibArt, 
                   family = binomial(link = "logit"))

summary(libarts_logit)

# Predicted Probability of Replying to the Liberal Student, Liberal Arts Colleges
x.Liberal.LibArts <- c(1, 1, 0)
z.Liberal.LibArts  <- sum(libarts_logit$coef * x.Liberal.LibArts )
pp_Liberal_LibArts <- plogis(z.Liberal.LibArts) 

# Predicted Probability of Replying to the Control Student, Liberal Arts Colleges
x.Control.LibArts <- c(1, 0, 0)
z.Control.LibArts  <- sum(libarts_logit$coef * x.Control.LibArts )
pp_Control_LibArts <- plogis(z.Control.LibArts) 

# Predicted Probability of Replying to the Conservative Student, Liberal Arts Colleges
x.Conservative.LibArts <- c(1, 0, 1)
z.Conservative.LibArts  <- sum(libarts_logit$coef * x.Conservative.LibArts )
pp_Conservative_LibArts <- plogis(z.Conservative.LibArts) 

# Liberal Arts Colleges logit, no controls
libarts_logit <-glm(as.numeric(replied) ~ 
                     + I(condition=="Liberal") 
                   + I(condition=="Conservative"),
                   data = LibArt,
                  family = binomial(link = "logit"))

summary(libarts_logit)


logit_table_libarts <- stargazer(libarts_logit,
                                 dep.var.labels=c("Responsiveness"),
                                 covariate.labels=c("Liberal", "Conservative"))

# Treatment and DV Logit with Liberal Arts Colleges 
# Include religiosity, region, and setting since unbalanced as shown above
libarts_logit_controls <-glm(as.numeric(replied) ~ 
                              + I(condition=="Conservative")
                            + I(condition=="Liberal")
                            + I(setting=="urban")
                            + I(setting=="rural")
                            + I(region=="North") 
                            + I(region=="South") 
                            + I(region=="West")
                            + I(religious==1),
                            data = LibArt, 
                            family = binomial(link = "logit"))

summary(libarts_logit_controls)

# Treatment and DV OLS with Liberal Arts Colleges 
# Include religiosity, region, and setting since unbalanced as shown above
libarts_OLS_controls <-lm(as.numeric(replied) ~ 
                               + I(condition=="Conservative")
                             + I(condition=="Liberal")
                             + I(setting=="urban")
                             + I(setting=="rural")
                             + I(region=="North") 
                             + I(region=="South") 
                             + I(region=="West")
                             + I(religious==1),
                             data = LibArt)

summary(libarts_OLS_controls)

libart_logit <- stargazer(libarts_logit_controls,
                                       dep.var.labels=c("Responsiveness"),
                                       covariate.labels=c("Conservative", "Liberal",
                                                          "urban", "rural", "North", 
                                                          "South", "West", "religious"))

OLS_table_libarts <- stargazer(libarts_OLS,
                               dep.var.labels=c("Responsiveness"),
                               covariate.labels=c("Liberal", "Conservative"))

# Table 16: Treatment and DV Logit w Liberal Arts Colleges with controls 
library(Hmisc)
Variables <- matrix(NA, 9 ,3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","Conservative", "Liberal", "urban","rural", 
                         "North", "South",
                         "West", "religious") 
Variables[ ,1] <- round(as.numeric(libarts_logit_controls$coefficients), digits = 2)
Variables[ ,2] <- round(summary(libarts_logit_controls)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(libarts_logit_controls)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Lib Arts Logit with controls and enrollment interaction
libarts_logit_controls_interaction <-glm(as.numeric(replied) ~ 
                              + enrollment
                            + I(condition=="Conservative")
                            + I(condition=="Liberal")
                            + (I(condition=="Conservative") * enrollment)
                            + (I(condition=="Liberal") * enrollment)
                            + I(setting=="urban")
                            + I(setting=="rural")
                            + I(region=="North") 
                            + I(region=="South") 
                            + I(region=="West")
                            + I(religious==1),
                            data = LibArt, 
                            family = binomial(link = "logit"))

summary(libarts_logit_controls_interaction)

# Predicted Probability of Replying to the Liberal Student, Lib Arts Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Liberal.LibArts.controls <- c(1, 0, 1, 1, 0, 1, 0, 0, 0)
z.Liberal.LibArts.controls <- sum(libarts_logit_controls$coef * x.Liberal.LibArts.controls)
pp_Liberal_LibArts_controls <- plogis(z.Liberal.LibArts.controls) 

# Predicted Probability of Replying to the Conservative Student, Lib Arts Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Conservative.LibArts.controls <- c(1, 1, 0, 1, 0, 1, 0, 0, 0)
z.Conservative.LibArts.controls <- sum(libarts_logit_controls$coef * x.Conservative.LibArts.controls)
pp_Conservative_LibArts_controls <- plogis(z.Conservative.LibArts.controls) 

# Predicted Probability of Replying to the Control Student, Lib Arts Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Control.LibArts.controls <- c(1, 0, 0, 1, 0, 1, 0, 0, 0)
z.Control.LibArts.controls <- sum(libarts_logit_controls$coef * x.Control.LibArts.controls)
pp_Control_LibArts_controls <- plogis(z.Control.LibArts.controls) 

# Lib Arts OLS
# Treatment and DV Model with Liberal Arts Colleges 
# Include religiosity, region, and setting since unbalanced as shown above
libarts_OLS_controls <-lm(as.numeric(replied) ~ 
                            + I(condition=="Conservative")
                          + I(condition=="Liberal")
                          + I(setting=="urban")
                          + I(setting=="rural")
                          + I(region=="North") 
                          + I(region=="South") 
                          + I(region=="West")
                          + I(religious==1),
                          data = LibArt)

summary(libarts_OLS_controls)

# Lib Arts OLS
# Treatment and DV Model with Liberal Arts Colleges 
# Include religiosity, region, and setting since unbalanced as shown above
# Interact enrollment with treatment to test Hawthorne effect
libarts_OLS_controls_interaction <-lm(as.numeric(replied) ~ 
                                      + I(condition=="Liberal")
                                      + I(condition=="Conservative")
                                      + enrollment
                                      + (I(condition=="Liberal") * enrollment)
                                      + (I(condition=="Conservative") * enrollment)
                                      + I(setting=="urban")
                                      + I(setting=="rural")
                                      + I(region=="North") 
                                      + I(region=="South") 
                                      + I(region=="West")
                                      + I(religious==1),
                                      data = LibArt)

summary(libarts_OLS_controls_interaction)

# OLS with interaction, overall sample
OLS_Hawthorne <-lm(as.numeric(replied) ~ 
                     + I(condition=="Liberal") 
                   + I(condition=="Conservative")
                   + enrollment
                   + (I(condition=="Liberal")*enrollment)
                   + (I(condition=="Conservative")*enrollment),
                   data = deidgroup)

summary(OLS_Hawthorne)

# OLS with interaction, lib arts sample
# Interact enrollment with treatment to test Hawthorne effect
libarts_OLS_interaction <-lm(as.numeric(replied) ~ 
                                        + I(condition=="Liberal")
                                      + I(condition=="Conservative")
                                      + enrollment
                                      + (I(condition=="Liberal") * enrollment)
                                      + (I(condition=="Conservative") * enrollment),
                                      data = LibArt)

summary(libarts_OLS_interaction)

OLS_interaction_table <- stargazer(OLS_Hawthorne, libarts_OLS_interaction,
                         dep.var.labels=c("responsiveness", "responsiveness"),
                         covariate.labels=c("Liberal", "Conservative", "Enrollment", "Liberal x Enrollment",
                        "Conservative x Enrollment"))

# NonSouthern Colleges Dataset
NonSoutherndata <- deidgroup[deidgroup$region != "South", ]

# Non South, Treatment and DV Model
NonSouthmodel_controls <-glm(as.numeric(replied) ~ 
                               + I(condition=="Conservative")
                             + I(condition=="Liberal")
                             + I(setting=="urban")
                             + I(setting=="rural")
                             + endowment + enrollment + ranking
                             + I(religious==1)
                             + as.factor(num_school_type),
                             data = NonSoutherndata, 
                             family = binomial(link = "logit"))

summary(NonSouthmodel_controls)

# Table 18: Non-Southern Colleges, Treatment and DV Model
library(Hmisc)
Variables <- matrix(NA, 12, 3)
colnames(Variables) <- c("Coefficient", "Std. Error", "p-value")
rownames(Variables) <- c("Intercept","Conservative", "Liberal", "urban","rural", "endowment", 
                         "enrollment", "ranking", "religious", "Liberal Arts", 
                         "Regional University","Regional College")

Variables[ ,1] <- round(as.numeric(NonSouthmodel_controls$coefficients), digits = 2)
Variables[ ,2] <- round(summary(NonSouthmodel_controls)$coefficients[ ,2], digits = 2)
Variables[ ,3] <- round(summary(NonSouthmodel_controls)$coefficients[ ,4], digits = 2)
latex(Variables, file = "")

# Predicted Probability of Replying to the Liberal Student, NonSouthern Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Liberal.NonSouth.controls <- c(1, 0, 1, 1, 0, 5, 5, 5, 0, 0, 1, 0)
z.Liberal.NonSouth.controls <- sum(NonSouthmodel_controls$coef * x.Liberal.NonSouth.controls)
pp_Liberal_NonSouth_controls <- plogis(z.Liberal.NonSouth.controls) 

# Predicted Probability of Replying to the Conservative Student, NonSouthern Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Conservative.NonSouth.controls <- c(1, 1, 0, 1, 0, 5, 5, 5, 0, 0, 1, 0)
z.Conservative.NonSouth.controls <- sum(NonSouthmodel_controls$coef * x.Conservative.NonSouth.controls)
pp_Conservative_NonSouth_controls <- plogis(z.Conservative.NonSouth.controls) 
pp_Conservative_NonSouth_controls-pp_Liberal_NonSouth_controls

# Predicted Probability of Replying to the Control Student, NonSouthern Sample with Controls
# Average Case Approach using Median/Modal College Characteristics
x.Control.NonSouth.controls <- c(1, 0, 0, 1, 0, 5, 5, 5, 0, 0, 1, 0)
z.Control.NonSouth.controls <- sum(NonSouthmodel_controls$coef * x.Control.NonSouth.controls)
pp_Control_NonSouth_controls <- plogis(z.Control.NonSouth.controls) 

# Predicted Probability of Response for Southern Colleges
# Southern Colleges Dataset
South <- deidgroup[deidgroup$region == "South", ]

# Model with Southern Colleges Data
Southmodel <-glm(as.numeric(replied) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = South, 
                 family = binomial(link = "logit"))

summary(Southmodel)

# Predicted Probability of Replying to the Liberal Student, Southern Colleges
x.Liberal.South <- c(1, 1, 0)
z.Liberal.South <- sum(Southmodel$coef * x.Liberal.South)
pp_Liberal_South <- plogis(z.Liberal.South) 

# Predicted Probability of Replying to the Control Student, Southern Colleges
x.Control.South <- c(1, 0, 0)
z.Control.South  <- sum(Southmodel$coef * x.Control.South)
pp_Control_South <- plogis(z.Control.South) 

# Predicted Probability of Replying to the Conservative Student, Southern Colleges
x.Conservative.South <- c(1, 0, 1)
z.Conservative.South  <- sum(Southmodel$coef * x.Conservative.South )
pp_Conservative_South <- plogis(z.Conservative.South) 

# Predicted Probability of Response for NonSouthern Colleges
# NonSouthern Colleges Dataset
NonSouth <- deidgroup[deidgroup$region != "South", ]

# Model with NonSouthern Colleges Data
NonSouthmodel <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = NonSouth, 
                    family = binomial(link = "logit"))

summary(NonSouthmodel)

# Predicted Probability of Replying to the Liberal Student, NonSouthern Colleges
x.Liberal.NonSouth <- c(1, 1, 0)
z.Liberal.NonSouth <- sum(NonSouthmodel$coef * x.Liberal.NonSouth)
pp_Liberal_NonSouth <- plogis(z.Liberal.NonSouth) 

# Predicted Probability of Replying to the Control Student, NonSouthern Colleges
x.Control.NonSouth <- c(1, 0, 0)
z.Control.NonSouth  <- sum(NonSouthmodel$coef * x.Control.NonSouth)
pp_Control_NonSouth <- plogis(z.Control.NonSouth) 

# Predicted Probability of Replying to the Conservative Student, NonSouthern Colleges
x.Conservative.NonSouth <- c(1, 0, 1)
z.Conservative.NonSouth  <- sum(NonSouthmodel$coef * x.Conservative.NonSouth )
pp_Conservative_NonSouth <- plogis(z.Conservative.NonSouth) 

# Predicted Probability of Response for Religious Colleges
# Religious Colleges Dataset
Religious <- deidgroup[deidgroup$religious == 1, ]

# Model with Religious Colleges Data
Religiousmodel <-glm(as.numeric(replied) ~ 
                       + I(condition=="Liberal") 
                     + I(condition=="Conservative"),
                     data = Religious, 
                     family = binomial(link = "logit"))

summary(Religiousmodel)

# Predicted Probability of Replying to the Liberal Student, Religious Colleges
x.Liberal.Religious <- c(1, 1, 0)
z.Liberal.Religious <- sum(Religiousmodel$coef * x.Liberal.Religious)
pp_Liberal_Religious <- plogis(z.Liberal.Religious) 

# Predicted Probability of Replying to the Control Student, Religious Colleges
x.Control.Religious <- c(1, 0, 0)
z.Control.Religious  <- sum(Religiousmodel$coef * x.Control.Religious)
pp_Control_Religious <- plogis(z.Control.Religious) 

# Predicted Probability of Replying to the Conservative Student, Religious Colleges
x.Conservative.Religious <- c(1, 0, 1)
z.Conservative.Religious  <- sum(Religiousmodel$coef * x.Conservative.Religious)
pp_Conservative_Religious <- plogis(z.Conservative.Religious) 

# Predicted Probability of Response for NonReligious Colleges
# NonReligious Colleges Dataset
NonReligious <- deidgroup[deidgroup$religious == 0, ]

# Model with NonReligious Colleges Data
NonReligiousmodel <-glm(as.numeric(replied) ~ 
                          + I(condition=="Liberal") 
                        + I(condition=="Conservative"),
                        data = NonReligious, 
                        family = binomial(link = "logit"))

summary(NonReligiousmodel)

# Predicted Probability of Replying to the Liberal Student, NonReligious Colleges
x.Liberal.NonReligious <- c(1, 1, 0)
z.Liberal.NonReligious <- sum(NonReligiousmodel$coef * x.Liberal.NonReligious)
pp_Liberal_NonReligious <- plogis(z.Liberal.NonReligious) 

# Predicted Probability of Replying to the Control Student, NonReligious Colleges
x.Control.NonReligious <- c(1, 0, 0)
z.Control.NonReligious  <- sum(NonReligiousmodel$coef * x.Control.NonReligious)
pp_Control_NonReligious <- plogis(z.Control.NonReligious) 

# Predicted Probability of Replying to the Conservative Student, NonReligious Colleges
x.Conservative.NonReligious <- c(1, 0, 1)
z.Conservative.NonReligious  <- sum(NonReligiousmodel$coef * x.Conservative.NonReligious)
pp_Conservative_NonReligious <- plogis(z.Conservative.NonReligious) 

# Predicted Probability of Response for Urban Colleges
# Urban Colleges Dataset
Urban <- deidgroup[deidgroup$setting == "urban", ]

# Model with Urban Colleges Data
Urbanmodel <-glm(as.numeric(replied) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = Urban, 
                 family = binomial(link = "logit"))

summary(Urbanmodel)

# Predicted Probability of Replying to the Liberal Student, Urban Colleges
x.Liberal.Urban <- c(1, 1, 0)
z.Liberal.Urban <- sum(Urbanmodel$coef * x.Liberal.Urban)
pp_Liberal_Urban <- plogis(z.Liberal.Urban) 

# Predicted Probability of Replying to the Control Student, Urban Colleges
x.Control.Urban <- c(1, 0, 0)
z.Control.Urban  <- sum(Urbanmodel$coef * x.Control.Urban)
pp_Control_Urban <- plogis(z.Control.Urban) 

# Predicted Probability of Replying to the Conservative Student, Urban Colleges
x.Conservative.Urban <- c(1, 0, 1)
z.Conservative.Urban  <- sum(Urbanmodel$coef * x.Conservative.Urban)
pp_Conservative_Urban <- plogis(z.Conservative.Urban) 

# Predicted Probability of Response for Rural Colleges
# Rural Colleges Dataset
Rural <- deidgroup[deidgroup$setting == "rural", ]

# Model with Rural Colleges Data
Ruralmodel <-glm(as.numeric(replied) ~ 
                   + I(condition=="Liberal") 
                 + I(condition=="Conservative"),
                 data = Rural, 
                 family = binomial(link = "logit"))

summary(Ruralmodel)

# Predicted Probability of Replying to the Liberal Student, Rural Colleges
x.Liberal.Rural <- c(1, 1, 0)
z.Liberal.Rural <- sum(Ruralmodel$coef * x.Liberal.Rural)
pp_Liberal_Rural <- plogis(z.Liberal.Rural) 

# Predicted Probability of Replying to the Control Student, Rural Colleges
x.Control.Rural <- c(1, 0, 0)
z.Control.Rural  <- sum(Ruralmodel$coef * x.Control.Rural)
pp_Control_Rural <- plogis(z.Control.Rural) 

# Predicted Probability of Replying to the Conservative Student, Rural Colleges
x.Conservative.Rural <- c(1, 0, 1)
z.Conservative.Rural  <- sum(Ruralmodel$coef * x.Conservative.Rural)
pp_Conservative_Rural <- plogis(z.Conservative.Rural) 

# Generating Confidence Intervals from Bootstrap Samples of Predicted Probability Estimates ------------
# Confidence Interval Around Predicted Probability of Response to Liberal Student, Overall Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, Overall Sample
m <- 1
pp.boot. <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis (z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.overall <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.overall.low <- ordered.boot[25]
ci.Liberal.overall.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Overall Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.overall <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying in Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.overall.low <- ordered.boot[25]
ci.Control.overall.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, Overall Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.overall <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Conservative Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.overall.low <- ordered.boot[25]
ci.Conservative.overall.high <- ordered.boot[975]

# Confidence Intervals for National Liberal Arts College PP Estimates
# Confidence Interval Around Predicted Probability of Response to Liberal Student, LibArts Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, LibArts Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.LibArt <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.LibArt.low <- ordered.boot[25]
ci.Liberal.LibArt.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, LibArts Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, LibArts Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.LibArt <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.LibArt.low <- ordered.boot[25]
ci.Control.LibArt.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, LibArts Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, LibArts Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.LibArt <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Conservative Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.LibArt.low <- ordered.boot[25]
ci.Conservative.LibArt.high <- ordered.boot[975]

# Southern Schools 
# Confidence Interval Around Predicted Probability of Response to Liberal Student, Southern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, Southern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(South), replace = TRUE)
  dat.boot <- South[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.Southern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.Southern.low <- ordered.boot[25]
ci.Liberal.Southern.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Southern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, Southern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(South), replace = TRUE)
  dat.boot <- South[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.Southern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.Southern.low <- ordered.boot[25]
ci.Control.Southern.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, Southern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, Southern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(South), replace = TRUE)
  dat.boot <- South[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.Southern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Conservative Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.Southern.low <- ordered.boot[25]
ci.Conservative.Southern.high <- ordered.boot[975]

# NonSouth
# Confidence Interval Around Predicted Probability of Response to Liberal Student, NonSouthern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, NonSouthern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSouth), replace = TRUE)
  dat.boot <- NonSouth[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.NonSouthern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.NonSouthern.low <- ordered.boot[25]
ci.Liberal.NonSouthern.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, NonSouthern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, NonSouthern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSouth), replace = TRUE)
  dat.boot <- NonSouth[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.NonSouthern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.NonSouthern.low <- ordered.boot[25]
ci.Control.NonSouthern.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, NonSouthern Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, NonSouthern Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSouth), replace = TRUE)
  dat.boot <- NonSouth[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.NonSouthern <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Conservative Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.NonSouthern.low <- ordered.boot[25]
ci.Conservative.NonSouthern.high <- ordered.boot[975]

# Religious Schools
# Confidence Interval Around Predicted Probability of Response to Liberal Student, Religious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, Religious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Religious), replace = TRUE)
  dat.boot <- Religious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.Religious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.Religious.low <- ordered.boot[25]
ci.Liberal.Religious.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Religious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, Religious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Religious), replace = TRUE)
  dat.boot <- Religious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.Religious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.Religious.low <- ordered.boot[25]
ci.Control.Religious.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, Religious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, Religious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Religious), replace = TRUE)
  dat.boot <- Religious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.Religious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.Religious.low <- ordered.boot[25]
ci.Conservative.Religious.high <- ordered.boot[975]

# NonReligious
# Confidence Interval Around Predicted Probability of Response to Liberal Student, NonReligious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, NonReligious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonReligious), replace = TRUE)
  dat.boot <- NonReligious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.NonReligious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.NonReligious.low <- ordered.boot[25]
ci.Liberal.NonReligious.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, NonReligious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, NonReligious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonReligious), replace = TRUE)
  dat.boot <- NonReligious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.NonReligious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.NonReligious.low <- ordered.boot[25]
ci.Control.NonReligious.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, NonReligious Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, NonReligious Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonReligious), replace = TRUE)
  dat.boot <- NonReligious[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.NonReligious <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Conservative Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.NonReligious.low <- ordered.boot[25]
ci.Conservative.NonReligious.high <- ordered.boot[975]

# Urban
# Confidence Interval Around Predicted Probability of Response to Liberal Student, Urban Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, Urban Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Urban), replace = TRUE)
  dat.boot <- Urban[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.Urban <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.Urban.low <- ordered.boot[25]
ci.Liberal.Urban.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Urban Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, Urban Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Urban), replace = TRUE)
  dat.boot <- Urban[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.Urban <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.Urban.low <- ordered.boot[25]
ci.Control.Urban.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, Urban Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, Urban Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Urban), replace = TRUE)
  dat.boot <- Urban[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.Urban <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.Urban.low <- ordered.boot[25]
ci.Conservative.Urban.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Liberal Student, Rural Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Liberal Student, Rural Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Rural), replace = TRUE)
  dat.boot <- Rural[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,1,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.Rural <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.Rural.low <- ordered.boot[25]
ci.Liberal.Rural.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Rural Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Control Student, Rural Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Rural), replace = TRUE)
  dat.boot <- Rural[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,0)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.Rural <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.Rural.low <- ordered.boot[25]
ci.Control.Rural.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, Rural Sample
# Bootstrap: 1000 Estimates of Predicted Probability of Response to Conservative Student, Rural Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(Rural), replace = TRUE)
  dat.boot <- Rural[sel,]
  
  # run logit in bootstrap sample
  reply_model <-glm(as.numeric(replied) ~ 
                      + I(condition=="Liberal") 
                    + I(condition=="Conservative"),
                    data = dat.boot, 
                    family = binomial(link = "logit"))
  
  summary(reply_model)
  
  # compute pp for bootstrap sample
  x <- c(1,0,1)
  z <- sum(reply_model$coefficients*x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.Rural <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.Rural.low <- ordered.boot[25]
ci.Conservative.Rural.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Liberal Student, Lib Arts Sample
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  libartsmodel_controls <-glm(as.numeric(replied) ~ 
                                + I(condition=="Conservative")
                              + I(condition=="Liberal")
                              + I(setting=="urban")
                              + I(setting=="rural")
                              + I(region=="North") 
                              + I(region=="South") 
                              + I(region=="West")
                              + I(religious==1),
                              data = dat.boot, 
                              family = binomial(link = "logit"))
  
  summary(libartsmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 0, 1, 1, 0, 1, 0, 0, 0)
  z <- sum(libartsmodel_controls$coef * x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.LibArt.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.LibArt.controls.low <- ordered.boot[25]
ci.Liberal.LibArt.controls.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, Lib Arts Sample
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  libartsmodel_controls <-glm(as.numeric(replied) ~ 
                                + I(condition=="Conservative")
                              + I(condition=="Liberal")
                              + I(setting=="urban")
                              + I(setting=="rural")
                              + I(region=="North") 
                              + I(region=="South") 
                              + I(region=="West")
                              + I(religious==1),
                              data = dat.boot, 
                              family = binomial(link = "logit"))
  
  summary(libartsmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 0, 0, 1, 0, 1, 0, 0, 0)
  z <- sum(libartsmodel_controls$coef * x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.LibArt.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Control Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.LibArt.controls.low <- ordered.boot[25]
ci.Control.LibArt.controls.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, 
# Lib Arts Sample
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(LibArt), replace = TRUE)
  dat.boot <- LibArt[sel,]
  
  # run logit in bootstrap sample
  libartsmodel_controls <-glm(as.numeric(replied) ~ 
                                + I(condition=="Conservative")
                              + I(condition=="Liberal")
                              + I(setting=="urban")
                              + I(setting=="rural")
                              + I(region=="North") 
                              + I(region=="South") 
                              + I(region=="West")
                              + I(religious==1),
                              data = dat.boot, 
                              family = binomial(link = "logit"))
  
  summary(libartsmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 1, 0, 1, 0, 1, 0, 0, 0)
  z <- sum(libartsmodel_controls$coef * x)
  pp.boot[m] <- plogis(z)
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.LibArt.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.LibArt.controls.low <- ordered.boot[25]
ci.Conservative.LibArt.controls.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Liberal Student, 
# NonSouthern Sample 
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSoutherndata), replace = TRUE)
  dat.boot <- NonSoutherndata[sel,]
  
  # run logit in bootstrap sample
  NonSouthmodel_controls <-glm(as.numeric(replied) ~ 
                                 + I(condition=="Conservative")
                               + I(condition=="Liberal")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(religious==1)
                               + as.factor(num_school_type),
                               data = dat.boot, 
                               family = binomial(link = "logit"))
  
  summary(NonSouthmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 0, 1, 1, 0, 5, 5, 5, 0, 0, 1, 0)
  z <- sum(NonSouthmodel_controls$coef * x)
  pp.boot[m] <- plogis(z) 
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Liberal.NonSouth.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Liberal.NonSouth.controls.low <- ordered.boot[25]
ci.Liberal.NonSouth.controls.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Conservative Student, 
# NonSouthern Sample 
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSoutherndata), replace = TRUE)
  dat.boot <- NonSoutherndata[sel,]
  
  # run logit in bootstrap sample
  NonSouthmodel_controls <-glm(as.numeric(replied) ~ 
                                 + I(condition=="Conservative")
                               + I(condition=="Liberal")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(religious==1)
                               + as.factor(num_school_type),
                               data = dat.boot, 
                               family = binomial(link = "logit"))
  
  summary(NonSouthmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 1, 0, 1, 0, 5, 5, 5, 0, 0, 1, 0)
  z <- sum(NonSouthmodel_controls$coef * x)
  pp.boot[m] <- plogis(z) 
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Conservative.NonSouth.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Conservative.NonSouth.controls.low <- ordered.boot[25]
ci.Conservative.NonSouth.controls.high <- ordered.boot[975]

# Confidence Interval Around Predicted Probability of Response to Control Student, 
# NonSouthern Sample 
# model with controls
# Bootstrap: 1000 Estimates of Predicted Probability of Response 
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(NonSoutherndata), replace = TRUE)
  dat.boot <- NonSoutherndata[sel,]
  
  # run logit in bootstrap sample
  NonSouthmodel_controls <-glm(as.numeric(replied) ~ 
                                 + I(condition=="Conservative")
                               + I(condition=="Liberal")
                               + I(setting=="urban")
                               + I(setting=="rural")
                               + endowment + enrollment + ranking
                               + I(religious==1)
                               + as.factor(num_school_type),
                               data = dat.boot, 
                               family = binomial(link = "logit"))
  
  summary(NonSouthmodel_controls)
  
  # compute pp for bootstrap sample
  x <- c(1, 0, 0, 1, 0, 5, 5, 5, 0, 0, 1, 0)
  z <- sum(NonSouthmodel_controls$coef * x)
  pp.boot[m] <- plogis(z) 
  
  cat(m,"\n")
}

# Standard error = standard deviation of sampling distribution
boot.se.Control.NonSouth.controls <- sd(pp.boot)

# Percentile Theory Confidence Intervals for Predicted Probability of Replying to Liberal Student
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
ci.Control.NonSouth.controls.low <- ordered.boot[25]
ci.Control.NonSouth.controls.high <- ordered.boot[975]

# Predicted Probability Plots -------------------------------------------------------------------------------------
# Predicted Probability of Response Across Conditions, Overall Sample
pp.vector <- c(pp_Liberal_overall, pp_Control_overall, pp_Conservative_overall)
labels <- c("\nLiberal \nCondition", "\nControl \nCondition", "\nConservative \nCondition")
treats <- c(0,1,2)

# 95% Percentile Theory Confidence Intervals
upper.ci.overall <- c(ci.Liberal.overall.high, ci.Control.overall.high, ci.Conservative.overall.high)
lower.ci.overall <- c(ci.Liberal.overall.low, ci.Control.overall.low, ci.Conservative.overall.low)

# 95% Normal Theory Confidence Intervals
up.ci.overall <- c(pp_Liberal_overall + 1.96*boot.se.Liberal.overall,
                   pp_Control_overall + 1.96*boot.se.Control.overall, 
                   pp_Conservative_overall + 1.96*boot.se.Conservative.overall)
low.ci.overall <- c(pp_Liberal_overall - 1.96*boot.se.Liberal.overall,
                    pp_Control_overall - 1.96*boot.se.Control.overall, 
                    pp_Conservative_overall - 1.96*boot.se.Conservative.overall)

# Figure 1
# plot of predicted probability of response in each group with 95% Normal Theory confidence intervals, overall sample
pp.plot <- plot(treats, pp.vector, family = "serif", ylim=c(.5,.8), xlab="Experimental Group", 
                ylab="Predicted Probability of Response", xaxt = 'n' )
arrows(treats, low.ci.overall, treats, up.ci.overall, length=0.05, angle=90, code=3)
axis(1, at=0:2, family = "serif", labels=labels)

# Predicted Probability of Response Across Conditions, National Liberal Arts Colleges, no controls 
pp.vector.libarts <- c(pp_Liberal_LibArts, pp_Control_LibArts, pp_Conservative_LibArts)
labels <- c("\nLiberal \nCondition", "\nControl \nCondition", "\nConservative \nCondition")
treats <- c(0,1,2)

# 95% Normal Theory Confidence Intervals
up.ci.libarts <- c(pp_Liberal_LibArts + 1.96*boot.se.Liberal.LibArt,
                   pp_Control_LibArts + 1.96*boot.se.Control.LibArt, 
                   pp_Conservative_LibArts + 1.96*boot.se.Conservative.LibArt)
low.ci.libarts <- c(pp_Liberal_LibArts - 1.96*boot.se.Liberal.LibArt,
                    pp_Control_LibArts - 1.96*boot.se.Control.LibArt, 
                    pp_Conservative_LibArts - 1.96*boot.se.Conservative.LibArt)

# Figure in 9/5/19 version
# plot of predicted probability of response, 95% Normal Theory confidence intervals, Liberal Arts Colleges
pp.plot.LibArts <- plot(treats, pp.vector.libarts, family = "serif",
                        ylim=c(.25,.85), xlab="Experimental Group",  xaxt = 'n',  
                        ylab="Predicted Probability of Response")
arrows(treats, low.ci.libarts, treats, up.ci.libarts, length=0.05, angle=90, code=3)
axis(1, at=0:2, family = "serif", labels=labels)

# Predicted Probability of Response Across Conditions, National Liberal Arts Colleges, with controls 
pp.vector.libarts.controls <- c(pp_Liberal_LibArts_controls, pp_Control_LibArts_controls,
                                pp_Conservative_LibArts_controls)
labels <- c("\nLiberal \nCondition", "\nControl \nCondition", "\nConservative \nCondition")
treats <- c(0,1,2)

# 95% Normal Theory Confidence Intervals
up.ci.libarts.controls <- c(pp_Liberal_LibArts_controls + 1.96*boot.se.Liberal.LibArt.controls,
                            pp_Control_LibArts_controls + 1.96*boot.se.Control.LibArt.controls, 
                            pp_Conservative_LibArts_controls + 1.96*boot.se.Conservative.LibArt.controls )
low.ci.libarts.controls <- c(pp_Liberal_LibArts_controls - 1.96*boot.se.Liberal.LibArt.controls,
                             pp_Control_LibArts_controls - 1.96*boot.se.Control.LibArt.controls, 
                             pp_Conservative_LibArts_controls - 1.96*boot.se.Conservative.LibArt.controls)

# Figure 3 in new (9/5/19 version)
# plot of predicted probability of response, 95% Normal Theory confidence intervals, with controls
# Liberal Arts Colleges
pp.plot.LibArts.controls <- plot(treats, pp.vector.libarts.controls, 
                                 main= "Figure 3: Predicted Probability of Response, \nNational Liberal Arts Colleges, with Controls", 
                                 ylim=c(0,1), xlab="Experimental Group",  xaxt = 'n',  
                                 ylab="Predicted Probability of Response")
arrows(treats, low.ci.libarts.controls, treats, up.ci.libarts.controls, length=0.05, angle=90, code=3)
axis(1, at=0:2, labels=labels)

# Predicted Probability of Response Across Conditions, South v NonSouth 
pp.vector.southnot <- c(pp_Liberal_South, pp_Control_South, pp_Conservative_South,
                        pp_Liberal_NonSouth, pp_Control_NonSouth, pp_Conservative_NonSouth)
labels <- c("\nLiberal \nSouth", "\nControl \nSouth", 
            "\nConservative \nSouth", 
            "\nLiberal \nNonSouth", "\nControl \nNonSouth", 
            "\nConservative \nNonSouth")
treats <- c(0,1,2,3,4,5)

# 95% Normal Theory Confidence Intervals
up.ci.southnot <- c(pp_Liberal_South + 1.96*boot.se.Liberal.Southern,
                    pp_Control_South + 1.96*boot.se.Control.Southern, 
                    pp_Conservative_South + 1.96*boot.se.Conservative.Southern,
                    pp_Liberal_NonSouth + 1.96*boot.se.Liberal.NonSouthern,
                    pp_Control_NonSouth + 1.96*boot.se.Control.NonSouthern, 
                    pp_Conservative_NonSouth + 1.96*boot.se.Conservative.NonSouthern)


low.ci.southnot <- c(pp_Liberal_South - 1.96*boot.se.Liberal.Southern,
                     pp_Control_South - 1.96*boot.se.Control.Southern, 
                     pp_Conservative_South - 1.96*boot.se.Conservative.Southern,
                     pp_Liberal_NonSouth - 1.96*boot.se.Liberal.NonSouthern,
                     pp_Control_NonSouth - 1.96*boot.se.Control.NonSouthern, 
                     pp_Conservative_NonSouth - 1.96*boot.se.Conservative.NonSouthern)

# Figure 3
# plot of predicted probability of response, 95% Normal Theory confidence intervals, South/not
pp.plot.Southnot <- plot(treats, pp.vector.southnot, 
                         main= "Figure 3: Predicted Probability of Response, Colleges by Region", 
                         ylim=c(.5,.8), xlab="Experimental Group",  xaxt = 'n',  
                         ylab="Predicted Probability of Response")
arrows(treats, low.ci.southnot, treats, up.ci.southnot, length=0.05, angle=90, code=3)
axis(1, at=0:5, labels=labels)

# Predicted Probability of Response Across Conditions, Religious v NonReligious Colleges
pp.vector.religiousnot <- c(pp_Liberal_Religious, pp_Control_Religious, pp_Conservative_Religious,
                            pp_Liberal_NonReligious, pp_Control_NonReligious, pp_Conservative_NonReligious)
labels <- c("\nLiberal \nReligious", "\nControl \nReligious", 
            "\nConservative \nReligious", 
            "\nLiberal \nNonReligious", "\nControl \nNonReligious", 
            "\nConservative \nNonReligious")
treats <- c(0,1,2,3,4,5)

# 95% Normal Theory Confidence Intervals
up.ci.religiousnot <- c(pp_Liberal_Religious + 1.96*boot.se.Liberal.Religious,
                        pp_Control_Religious + 1.96*boot.se.Control.Religious, 
                        pp_Conservative_Religious + 1.96*boot.se.Conservative.Religious,
                        pp_Liberal_NonReligious + 1.96*boot.se.Liberal.NonReligious,
                        pp_Control_NonReligious + 1.96*boot.se.Control.NonReligious, 
                        pp_Conservative_NonReligious + 1.96*boot.se.Conservative.NonReligious)


low.ci.religiousnot <- c(pp_Liberal_Religious - 1.96*boot.se.Liberal.Religious,
                         pp_Control_Religious - 1.96*boot.se.Control.Religious, 
                         pp_Conservative_Religious - 1.96*boot.se.Conservative.Religious,
                         pp_Liberal_NonReligious - 1.96*boot.se.Liberal.NonReligious,
                         pp_Control_NonReligious - 1.96*boot.se.Control.NonReligious, 
                         pp_Conservative_NonReligious - 1.96*boot.se.Conservative.NonReligious)

# Figure 4
# plot of predicted probability of response, 95% Normal Theory confidence intervals, Religious/not
pp.plot.religiousnot <- plot(treats, pp.vector.religiousnot, 
                             main= "Figure 4: Predicted Probability of Response by Condition and College Religiosity", 
                             ylim=c(.5,.75), xlab="Experimental Group",  xaxt = 'n',  
                             ylab="Predicted Probability of Response")
arrows(treats, low.ci.religiousnot, treats, up.ci.religiousnot, length=0.05, angle=90, code=3)
axis(1, at=0:5, labels=labels)

# Predicted Probability of Response Across Conditions, Urban v Rural Colleges
pp.vector.setting <- c(pp_Liberal_Urban, pp_Control_Urban, pp_Conservative_Urban,
                       pp_Liberal_Rural, pp_Control_Rural, pp_Conservative_Rural)
labels <- c("\nLiberal \nUrban", "\nControl \nUrban", 
            "\nConservative \nUrban", 
            "\nLiberal \nRural", "\nControl \nRural", 
            "\nConservative \nRural")
treats <- c(0,1,2,3,4,5)

# 95% Normal Theory Confidence Intervals
up.ci.setting <- c(pp_Liberal_Urban + 1.96*boot.se.Liberal.Urban,
                   pp_Control_Urban + 1.96*boot.se.Control.Urban, 
                   pp_Conservative_Urban + 1.96*boot.se.Conservative.Urban,
                   pp_Liberal_Rural + 1.96*boot.se.Liberal.Rural,
                   pp_Control_Rural + 1.96*boot.se.Control.Rural, 
                   pp_Conservative_Rural + 1.96*boot.se.Conservative.Rural)

low.ci.setting <- c(pp_Liberal_Urban - 1.96*boot.se.Liberal.Urban,
                    pp_Control_Urban - 1.96*boot.se.Control.Urban, 
                    pp_Conservative_Urban - 1.96*boot.se.Conservative.Urban,
                    pp_Liberal_Rural - 1.96*boot.se.Liberal.Rural,
                    pp_Control_Rural - 1.96*boot.se.Control.Rural, 
                    pp_Conservative_Rural - 1.96*boot.se.Conservative.Rural)

# Figure 3 in New (Aug 12, 2019) Version
# plot of predicted probability of response, 95% Normal Theory confidence intervals, Liberal Arts Colleges
pp.plot.setting <- plot(treats, pp.vector.setting, 
                        main= "Predicted Probability of Response by Condition and College Setting", 
                        ylim=c(.5,.85), xlab="Experimental Group",  xaxt = 'n',  
                        ylab="Predicted Probability of Response")
arrows(treats, low.ci.setting, treats, up.ci.setting, length=0.05, angle=90, code=3)
axis(1, at=0:5, labels=labels)

# Predicted Probability of Response Across Conditions, NonSouthern Colleges, with controls 
pp.vector.nonsouth.controls <- c(pp_Liberal_NonSouth_controls, pp_Control_NonSouth_controls,
                                 pp_Conservative_NonSouth_controls)
labels <- c("\nLiberal \nCondition", "\nControl \nCondition", "\nConservative \nCondition")
treats <- c(0,1,2)

# 95% Normal Theory Confidence Intervals
up.ci.nonsouth.controls <- c(pp_Liberal_NonSouth_controls + 1.96*boot.se.Liberal.NonSouth.controls,
                             pp_Control_NonSouth_controls + 1.96*boot.se.Control.NonSouth.controls, 
                             pp_Conservative_NonSouth_controls + 1.96*boot.se.Conservative.NonSouth.controls )
low.ci.nonsouth.controls <- c(pp_Liberal_NonSouth_controls - 1.96*boot.se.Liberal.NonSouth.controls,
                              pp_Control_NonSouth_controls - 1.96*boot.se.Control.NonSouth.controls, 
                              pp_Conservative_NonSouth_controls - 1.96*boot.se.Conservative.NonSouth.controls)

# Figure 5 
# plot of predicted probability of response, 95% Normal Theory confidence intervals, with controls
# Liberal Arts Colleges
pp.plot.NonSouth.controls <- plot(treats, pp.vector.nonsouth.controls, 
                                  main= "Figure 5: Predicted Probability of Response, \nColleges Outside the South, with Controls", 
                                  ylim=c(.5,.9), xlab="Experimental Group",  xaxt = 'n',  
                                  ylab="Predicted Probability of Response")
arrows(treats, low.ci.nonsouth.controls, treats, up.ci.nonsouth.controls, length=0.05, angle=90, code=3)
axis(1, at=0:2, labels=labels)

# New Table 1 Option B (Observed Response Rates with Standard Errors of PP of Response)

# Combining all sample sizes, observed response rates, and standard deviations into vectors for table
n_liberal <- c(Overall_Liberal_n, LibArts_Liberal_n, South_Liberal_n, NonSouth_Liberal_n, Religious_Liberal_n,
               NonReligious_Liberal_n, Urban_Liberal_n, Rural_Liberal_n)

n_control <- c(Overall_Control_n, LibArts_Control_n, South_Control_n, NonSouth_Control_n, Religious_Control_n,
               NonReligious_Control_n, Urban_Control_n, Rural_Control_n)

n_conservative <- c(Overall_Conservative_n, LibArts_Conservative_n, South_Conservative_n, NonSouth_Conservative_n, 
                    Religious_Conservative_n, NonReligious_Conservative_n, Urban_Conservative_n, Rural_Conservative_n)

observed_rrs_liberal <- c(Observed_rr_overall_Liberal, Observed_rr_LibArts_Liberal, Observed_rr_Southern_Liberal,
                          Observed_rr_NonSouthern_Liberal, Observed_rr_Religious_Liberal, 
                          Observed_rr_NonReligious_Liberal, Observed_rr_Urban_Liberal, Observed_rr_Rural_Liberal)

observed_rrs_control <- c(Observed_rr_overall_Control, Observed_rr_LibArts_Control, Observed_rr_Southern_Control,
                          Observed_rr_NonSouthern_Control, Observed_rr_Religious_Control, 
                          Observed_rr_NonReligious_Control, Observed_rr_Urban_Control, Observed_rr_Rural_Control)

observed_rrs_conservative <- c(Observed_rr_overall_Conservative, Observed_rr_LibArts_Conservative,
                               Observed_rr_Southern_Conservative, Observed_rr_NonSouthern_Conservative, 
                               Observed_rr_Religious_Conservative, Observed_rr_NonReligious_Conservative, 
                               Observed_rr_Urban_Conservative, Observed_rr_Rural_Conservative)

# Rounding Standard Errors
# Liberal Condition
boot.se.Liberal.overall <- round(boot.se.Liberal.overall, digits = 2)
boot.se.Liberal.LibArt <- round(boot.se.Liberal.LibArt, digits =2) 
boot.se.Liberal.Southern <- round(boot.se.Liberal.Southern, digits =2)
boot.se.Liberal.NonSouthern <- round(boot.se.Liberal.NonSouthern, digits =2)
boot.se.Liberal.Religious <- round(boot.se.Liberal.Religious, digits =2)
boot.se.Liberal.NonReligious <- round(boot.se.Liberal.NonReligious, digits =2)
boot.se.Liberal.Urban <- round(boot.se.Liberal.Urban, digits =2)
boot.se.Liberal.Rural <- round(boot.se.Liberal.Rural, digits =2)

# Rounding Standard Errors
# Control Condition
boot.se.Control.overall <- round(boot.se.Control.overall, digits = 2)
boot.se.Control.LibArt <- round(boot.se.Control.LibArt, digits =2) 
boot.se.Control.Southern <- round(boot.se.Control.Southern, digits =2)
boot.se.Control.NonSouthern <- round(boot.se.Control.NonSouthern, digits =2)
boot.se.Control.Religious <- round(boot.se.Control.Religious, digits =2)
boot.se.Control.NonReligious <- round(boot.se.Control.NonReligious, digits =2)
boot.se.Control.Urban <- round(boot.se.Control.Urban, digits =2)
boot.se.Control.Rural <- round(boot.se.Control.Rural, digits =2)

# Rounding Standard Errors
# Conservative Condition
boot.se.Conservative.overall <- round(boot.se.Conservative.overall, digits = 2)
boot.se.Conservative.LibArt <- round(boot.se.Conservative.LibArt, digits =2) 
boot.se.Conservative.Southern <- round(boot.se.Conservative.Southern, digits =2)
boot.se.Conservative.NonSouthern <- round(boot.se.Conservative.NonSouthern, digits =2)
boot.se.Conservative.Religious <- round(boot.se.Conservative.Religious, digits =2)
boot.se.Conservative.NonReligious <- round(boot.se.Conservative.NonReligious, digits =2)
boot.se.Conservative.Urban <- round(boot.se.Conservative.Urban, digits =2)
boot.se.Conservative.Rural <- round(boot.se.Conservative.Rural, digits =2)

observed_se_liberal <- c(boot.se.Liberal.overall, boot.se.Liberal.LibArt, 
                         boot.se.Liberal.Southern, boot.se.Liberal.NonSouthern,
                         boot.se.Liberal.Religious, boot.se.Liberal.NonReligious,
                         boot.se.Liberal.Urban, boot.se.Liberal.Rural)

observed_se_control <- c(boot.se.Control.overall, boot.se.Control.LibArt,
                         boot.se.Control.Southern, boot.se.Control.NonSouthern,
                         boot.se.Control.Religious, boot.se.Control.NonReligious,
                         boot.se.Control.Urban, boot.se.Control.Rural)

observed_se_conservative <- c(boot.se.Conservative.overall, boot.se.Conservative.LibArt,
                              boot.se.Conservative.Southern, boot.se.Conservative.NonSouthern,
                              boot.se.Conservative.Religious, boot.se.Conservative.NonReligious,
                              boot.se.Conservative.Urban, boot.se.Conservative.Rural)

# New (Aug 13, 2019)
# Table 1 Option B: Observed Response Rates Across Conditions and by School Characteristics with n and Std. Deviation
library(Hmisc)
Sample <- matrix(NA, 8, 9)
colnames(Sample) <- c("Lib. \n n", "Contr. \n n", "Conserv. \n n", 
                      "Lib. \n RR", "Contr. \n RR", "Conserv. \n RR", 
                      "Lib. \n SE", "Contr. \n SE", "Conserv. \n SE")
rownames(Sample) <- c("Overall", "Liberal Arts", "South", "Non-South", "Religious", "Non-Religious", "Urban", "Rural") 
Sample[ ,1] <- n_liberal
Sample[ ,2] <- n_control
Sample[ ,3] <- n_conservative
Sample[ ,4] <- observed_rrs_liberal
Sample[ ,5] <- observed_rrs_control
Sample[ ,6] <- observed_rrs_conservative
Sample[ ,7] <- observed_se_liberal
Sample[ ,8] <- observed_se_control
Sample[ ,9] <- observed_se_conservative
latex(Sample, file = "")

# Adjusting for Multiple Comparisons
pvalues_multiple_comparisons <- as.numeric(c(Liberal_Control_DoM_p, Conservative_Control_DoM_p, 
                                             Liberal_Conservative_DoM_p, 
                                             LibArts_Liberal_Control_DoM_p,
                                             LibArts_Conservative_Control_DoM_p, 
                                             LibArts_Liberal_Conservative_DoM_p, 
                                             Religious_Liberal_Control_DoM_p, 
                                             Religious_Conservative_Control_DoM_p, 
                                             Religious_Liberal_Conservative_DoM_p, 
                                             NonReligious_Liberal_Control_DoM_p,
                                             NonReligious_Conservative_Control_DoM_p, 
                                             NonReligious_Liberal_Conservative_DoM_p,
                                             Southern_Liberal_Control_DoM_p, 
                                             Southern_Conservative_Control_DoM_p, 
                                             Southern_Liberal_Conservative_DoM_p, 
                                             NonSouthern_Liberal_Control_DoM_p,
                                             NonSouthern_Conservative_Control_DoM_p, 
                                             NonSouthern_Liberal_Conservative_DoM_p,
                                             Urban_Liberal_Control_DoM_p, 
                                             Urban_Conservative_Control_DoM_p,
                                             Urban_Liberal_Conservative_DoM_p, 
                                             Rural_Liberal_Control_DoM_p,
                                             Rural_Conservative_Control_DoM_p, 
                                             Rural_Liberal_Conservative_DoM_p))

pvalues_bonferonni <- p.adjust(pvalues_multiple_comparisons, 
                               method = "bonferroni", n = length(pvalues_multiple_comparisons))

pvalues_holm <- p.adjust(pvalues_multiple_comparisons,
                         method = "holm", n = length(pvalues_multiple_comparisons))

pvalues_hochberg <- p.adjust(pvalues_multiple_comparisons,
                             method = "hochberg", n = length(pvalues_multiple_comparisons))

pvalues_hommel <- p.adjust(pvalues_multiple_comparisons,
                           method = "hommel", n = length(pvalues_multiple_comparisons))

pvalues_fdr <- p.adjust(pvalues_multiple_comparisons, 
                        method = "fdr", n = length(pvalues_multiple_comparisons))

# Statistical Power Tests
# Conservative and Control Conditions
install.packages('pwr')
library('pwr')
pwr.t2n.test(n1 = 466, n2= 459, d = .2, sig.level =.05, power = NULL)

# Liberal and Control Conditions
pwr.t2n.test(n1 = 463, n2= 459, d = .2, sig.level =.05, power = NULL)




# Generating Confidence Intervals from Bootstrap Samples of Difference of Means Estimates -----------------------------------
# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Conservative Reply at all
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Conservative Reply at all
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$replies[dat.boot$condition == "Conservative"], dat.boot$replies[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# 90% Percentile Theory Confidence Intervals for DoM Replying at All Liberal-Conservative
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.conservative.replies.low <- ordered.boot[50]
doM.liberal.conservative.replies.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Conservative Substantive replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Conservative Substantive replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$substantive[dat.boot$condition == "Conservative"], dat.boot$substantive[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# Percentile Theory Confidence Intervals for DoM Substantive replies Liberal-Conservative
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.conservative.substantive.low <- ordered.boot[50]
doM.liberal.conservative.substantive.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Conservative Days to replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Conservative Days to replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$days[dat.boot$condition == "Conservative"], dat.boot$days[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# Percentile Theory Confidence Intervals for DoM Days to replies, Liberal-Conservative
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.conservative.days.low <- ordered.boot[50]
doM.liberal.conservative.days.high <- ordered.boot[950]

# Liberal-Control Comparisons -------------
# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Control replies at all, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Control replies at all, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$replies[dat.boot$condition == "Control"], dat.boot$replies[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# Percentile Theory Confidence Intervals for DoM repliesing at All Liberal-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.control.replies.low <- ordered.boot[50]
doM.liberal.control.replies.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Control Substantive replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Control Substantive replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$substantive[dat.boot$condition == "Control"], dat.boot$substantive[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# Percentile Theory Confidence Intervals for DoM Substantive replies Liberal-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.control.substantive.low <- ordered.boot[50]
doM.liberal.control.substantive.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Liberal-Control Days to replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Liberal-Control Days to replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$days[dat.boot$condition == "Control"], dat.boot$days[dat.boot$condition == "Liberal"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# Percentile Theory Confidence Intervals for DoM Substantive replies Liberal-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.liberal.control.days.low <- ordered.boot[50]
doM.liberal.control.days.high <- ordered.boot[950]

# Conservative-Control Comparisons -------------
# 90% Percentile Theory Confidence Interval Around Difference of Means, Conservative-Control replies at all, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Conservative-Control replies at all, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$replies[dat.boot$condition == "Control"], dat.boot$replies[dat.boot$condition == "Conservative"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# 90% Percentile Theory Confidence Intervals for DoM repliesing at All Conservative-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.conservative.control.replies.low <- ordered.boot[50]
doM.conservative.control.replies.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Conservative-Control Substantive replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Conservative-Control Substantive replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$substantive[dat.boot$condition == "Control"], dat.boot$substantive[dat.boot$condition == "Conservative"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# 90% Percentile Theory Confidence Intervals for DoM Substantive replies Conservative-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.conservative.control.substantive.low <- ordered.boot[50]
doM.conservative.control.substantive.high <- ordered.boot[950]

# 90% Percentile Theory Confidence Interval Around Difference of Means, Conservative-Control Days to replies, overall sample
# Bootstrap: 1000 Estimates of Difference of Means, Conservative-Control Days to replies, Overall Sample
m <- 1
pp.boot <- rep(NA,1000)
set.seed(1)

for(m in 1:1000)	{
  
  # create bootstrap sample
  sel <- sample(1:nrow(deidgroup), replace = TRUE)
  dat.boot <- deidgroup[sel,]
  
  # T Test 
  testing <- t.test(dat.boot$days[dat.boot$condition == "Control"], dat.boot$days[dat.boot$condition == "Conservative"],
                    alternative = c("two.sided"))
  
  pp.boot[m] <- testing$estimate[1] - testing$estimate[2]
  
  cat(m,"\n")
}

# 90% Percentile Theory Confidence Intervals for DoM Days to replies Conservative-Control
ordered.boot <- sort(pp.boot,  decreasing = FALSE)
doM.conservative.control.days.low <- ordered.boot[50]
doM.conservative.control.days.high <- ordered.boot[950]

# Table Displaying Difference of Means Drawn from Posterior Distribution at 5th and 9th Percentiles
# Balance Test/ Equivalency Check Tables- All Emails Sent
# Liberal- All Emails Sent 
library(Hmisc)
Comparison <- matrix(NA, 9, 2)
colnames(Comparison) <- c("5th Percentile", "95th Percentile")
rownames(Comparison) <- c("Liberal-Conservative, Reply",
                          "Liberal-Conservative, Substantive",
                          "Liberal-Conservative, Days to Reply",
                          
                          "Liberal-Control, Reply",
                          "Liberal-Control, Substantive",
                          "Liberal-Control, Days to Reply",
                          
                          "Conservative-Control, Reply",
                          "Conservative-Control, Substantive",
                          "Conservative-Control, Days to Reply")

Comparison[1,1] <- round(doM.liberal.conservative.replies.low, digits =2) 
Comparison[1,2] <- round(doM.liberal.conservative.replies.high, digits =2)
Comparison[2,1] <- round(doM.liberal.conservative.substantive.low, digits =2)
Comparison[2,2] <- round(doM.liberal.conservative.substantive.high, digits =2)
Comparison[3,1] <- round(doM.liberal.conservative.days.low, digits =2)
Comparison[3,2] <- round(doM.liberal.conservative.days.high, digits =2)
Comparison[4,1] <- round(doM.liberal.control.replies.low, digits =2)
Comparison[4,2] <- round(doM.liberal.control.replies.high, digits =2)
Comparison[5,1] <- round(doM.liberal.control.substantive.low, digits =2)
Comparison[5,2] <- round(doM.liberal.control.substantive.high, digits =2)
Comparison[6,1] <- round(doM.liberal.control.days.low, digits =2)
Comparison[6,2] <- round(doM.liberal.control.days.high, digits =2)
Comparison[7,1] <- round(doM.conservative.control.replies.low, digits =2)
Comparison[7,2] <- round(doM.conservative.control.replies.high, digits =2)
Comparison[8,1] <- round(doM.conservative.control.substantive.low, digits =2)
Comparison[8,2] <- round(doM.conservative.control.substantive.high, digits =2)
Comparison[9,1] <- round(doM.conservative.control.days.low, digits =2)
Comparison[9,2] <- round(doM.conservative.control.days.high, digits =2)

latex(Comparison, file = "")

Variables[ ,3] <- round(summary(control_balance)$coefficients[ ,4], digits = 2)

# Map Showing Geographic Coverage of Schools in Sample ## States-Arrests Example
write.csv(deidgroup, "exported_data.csv")
write.csv

install.packages("usmap")
install.packages("scales")


collegeone <- read.csv("C:/Users/khanj/Desktop/publications/data/collegenumbersstudyone.csv")
collegeone <- as.data.frame(collegeone)

library(tidyverse)
library(usmap)
library(scales)
library(ggplot2)

college_numbers_one_plot <- plot_usmap(
            data = collegeone,
           values = 'colleges'
           ) +
             scale_fill_gradient(
              trans = 'log',
              labels = scales::label_number(big.mark = ','),
              breaks = c(1, 5, 10, 20, 30, 40, 50, 60, 100),
              high = '#0072B2',
              low = 'white'
              ) +
  theme(legend.position = 'top') +
  labs(fill = 'Number of Colleges') +
  guides(
    fill = guide_colorbar(
      barwidth = unit(10, 'cm')
    )
  )
  

            



